Home | History | Annotate | Download | only in net
History log of /src/sys/net/ppp_tty.c
RevisionDateAuthorComments
 1.73  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.72  21-Dec-2022  chs ppp: remove ioctls that never worked and crash the kernel

Remove vestigial bits of PPP HDLC support that never worked on netbsd.
The TIOCRCVFRAME ioctl was apparently intended to be called only from
within the kernel, but nothing prevents user code from calling this ioctl
and crashing the kernel.

Reported-by: syzbot+53e4620d0d17a4dd08fa@syzkaller.appspotmail.com
Reported-by: syzbot+d3a8b784fed1e32e0768@syzkaller.appspotmail.com
Reported-by: syzbot+375bab63345a6a7a3331@syzkaller.appspotmail.com
Reported-by: syzbot+ba7ac85196274a20b54a@syzkaller.appspotmail.com
Reported-by: syzbot+57ddb63a3d1d3299ef18@syzkaller.appspotmail.com
 1.71  26-Oct-2022  riastradh branches: 1.71.2;
ppp(4): Convert to ttylock/ttyunlock.
 1.70  04-May-2022  andvar fix various typos in comments and log messages.
 1.69  13-Dec-2021  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.

Reported-by: syzbot+699ce32cd32e2a670788@syzkaller.appspotmail.com
 1.68  27-Sep-2021  msaitoh Use unsigned to avoid undefined behavior in pppasyncstart().

Reported-by: syzbot+7c8c7977e2756ac13f0a@syzkaller.appspotmail.com
 1.67  29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.66  20-Sep-2019  maxv branches: 1.66.2;
dedup
 1.65  24-Jan-2019  knakahara branches: 1.65.4;
Add KERNEL_LOCK in ppptioctl() to protect struct ppp_softc members.

struct linesw.i_ioctl can be called without any preservation when the caller's
struct cdevsw is set D_MPSAFE such as ucom(4).
 1.64  07-Feb-2018  mrg branches: 1.64.2; 1.64.4;
ppprcvframe() has indentation issues.
 1.63  02-Oct-2016  christos branches: 1.63.6; 1.63.8;
MFREE -> m_free
 1.62  06-Aug-2016  pgoyette Modularize the ppp driver, and adjust dependencies of the compressor
modules.

For now, this is still included as a built-in module in GENERIC kernels.
 1.61  20-Jun-2016  knakahara branches: 1.61.2;
apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).
 1.60  10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.59  24-Aug-2015  pooka sprinkle _KERNEL_OPT
 1.58  22-May-2014  dholland branches: 1.58.4;
Use accessor functions for the tty's table of control characters.
(at least from outside the core tty sources)

Move some xon/xoff code from net/ppp_tty.c to kern/tty.c.
 1.57  05-Apr-2010  joerg branches: 1.57.18; 1.57.32;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.56  19-Jan-2010  pooka branches: 1.56.2; 1.56.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.55  07-May-2009  elad Introduce actions/requests to handle authorization for ppp(4), sl(4),
strip(4), btuart(4) and bcsp(4) network interfaces and devices.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/04/27/msg004955.html
 1.54  15-Apr-2009  elad Remove a few KAUTH_GENERIC_ISSUSER in favor of more descriptive
alternatives.

Discussed on tech-kern:

http://mail-index.netbsd.org/tech-kern/2009/04/11/msg004798.html

Input from ad@, christos@, dyoung@, tsutsui@.

Okay ad@.
 1.53  25-May-2008  ad branches: 1.53.6; 1.53.12;
Properly fix the "hanging in tty" bug that was worked around with cv_wakeup()
some time again.
 1.52  20-Feb-2008  matt branches: 1.52.6; 1.52.8; 1.52.10; 1.52.12;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)
 1.51  28-Nov-2007  ad Grab tty_lock in more places. Noted and tested by degroote@.
 1.50  12-Nov-2007  ad Call ttwakeup() with tty_lock held.
 1.49  10-Nov-2007  ad Call ttyflush() with tty_lock held.
 1.48  07-Nov-2007  ad Merge tty changes from the vmlocking branch.
 1.47  04-Mar-2007  christos branches: 1.47.2; 1.47.14; 1.47.16; 1.47.20; 1.47.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.46  04-Jan-2007  elad branches: 1.46.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.45  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.44  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43  23-Jul-2006  ad branches: 1.43.4; 1.43.6;
Use the LWP cached credentials where sane.
 1.42  14-May-2006  elad integrate kauth.
 1.41  11-Dec-2005  thorpej branches: 1.41.4; 1.41.6; 1.41.8; 1.41.10; 1.41.12;
ANSI function decls and application of static.
 1.40  11-Dec-2005  christos merge ktrace-lwp.
 1.39  27-Nov-2005  thorpej Overhaul how TTY line disciplines are handled:
- Replace references to linesw[0] with a ttyldisc_default() function
that returns the default ("termios") line discipline.
- The linesw[] array is gone, replaced by a linked list.
- ttyldisc_add() and ttyldisc_remove() have been replaced by
ttyldisc_attach() and ttyldisc_detach().
- Things that provide line disciplines are now responsible for
registering those disciplines with the system. The linesw
structures are no longer declared in tty_conf.c
- Line disciplines are now refcounted; a lookup causes a reference to
be held. ttyldisc_release() releases the reference. Attempts to
detach an in-use line discipline result in EBUSY.
- Fix function signature lossage in if_sl.c, if_strip.c, and tty_tb.c
that was masked by the old tty_conf.c
- tty_init() is no longer necessary; delete it and its call from main().
 1.38  11-Jun-2005  christos branches: 1.38.2; 1.38.8;
30393/Miles Nordin: PF/ALTQ does not work on ppp(4) interfaces
This is because the mbuf chain created did not have a header.
 1.37  29-May-2005  christos - sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.
 1.36  17-May-2005  christos Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.35  26-Feb-2005  perry nuke trailing whitespace
 1.34  01-Sep-2003  christos branches: 1.34.8; 1.34.10;
Add a new ioctl PPPIOCGRAWIN to get the last characters we got from the
remote site.
 1.33  26-Feb-2003  matt branches: 1.33.2;
Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.
 1.32  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.31  01-Jul-2002  itojun new copyright boilerplate from CMU. from openbsd
 1.30  17-Mar-2002  atatat branches: 1.30.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.29  05-Mar-2002  itojun bring in latest ALTQ from kjc. ALTQify some of the drivers.
 1.28  13-Nov-2001  lukem remove unnecessary #if NFOO > 0 .... #endif wrappers
 1.27  12-Nov-2001  lukem add RCSIDs
 1.26  18-Jul-2001  thorpej branches: 1.26.2;
bzero -> memset
 1.25  14-Jun-2001  itojun branches: 1.25.2;
change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.
 1.24  31-Mar-2001  enami Remove unnecessary test of tp->t_linesw against NULL; they are results
of confusion while correcting compilation error after t_line is
replaced with t_linesw.
 1.23  18-Jan-2001  jdolecek branches: 1.23.2;
constify
 1.22  12-Dec-2000  thorpej Adapt to bpfattach() changes, and further centralize the bpfattach()
and bpfdetach() calls into link-type subroutines where possible.
 1.21  02-Nov-2000  itojun sync with struct tty change (does it look correct?)
 1.20  30-Mar-2000  augustss Kill some more register declarations.
 1.19  23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.18  25-Aug-1999  christos branches: 1.18.2;
changes from ppp-2.3.9 [synchronous]
 1.17  24-May-1999  tron Fix kernel builds if ppp interface but no bpf filters are configured.
Patch supplied by Takahiro Kambe in PR kern/7639, also fixes PR kern/7632
by Bjoern Labitzke.
 1.16  11-May-1999  thorpej * Start out with a data link type of DLT_NULL. When we change an interface
to serial encap, change its data link type to DLT_PPP_SERIAL.
* Work around some serious bogosity in the filtering code which utterly
breaks proper functioning of BPF. The PPP code and pppd(8) WILL be changed
to fix this.
 1.15  12-Dec-1998  christos branches: 1.15.4;
#include "opt_ppp.h" otherwise struct ppp_softc can be the wrong size
(From mycroft)
 1.14  02-Aug-1998  sommerfe branches: 1.14.4;
Fix PR5898: ppp delays last packet.
 1.13  25-Mar-1997  christos make sure that the tty layer restarts the ppp layer when there is an error
such as out of buffer space.
 1.12  24-Mar-1997  christos Add missing slpx(); from Bill Sommerfeld
 1.11  12-Mar-1997  christos Update to ppp-2.3b4; from Paul Mackerras
 1.10  13-Oct-1996  christos backout previous kprintf change
 1.9  10-Oct-1996  christos - printf -> kprintf, sprintf -> ksprintf
 1.8  07-Sep-1996  mycroft Implement poll(2).
 1.7  14-Jun-1996  cgd avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.
 1.6  07-May-1996  thorpej Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_reset)()
to take a struct ifnet *, rather than a unit number.
 1.5  15-Mar-1996  paulus Added packet filtering, support for "PPP Deflate" packet compression,
trivial multicast support, and support for xon/xoff output flow
control to the PPP subsystem. Fixed several bugs, including making
the accumulation and resetting of statistics more consistent. State
for the VJ compressor is now dynamically allocated.
 1.4  13-Feb-1996  christos Net prototypes
 1.3  05-Oct-1995  mycroft Add some missing statistics. From Thorsten Lockert.
 1.2  04-Jul-1995  paulus Change $Id to $NetBSD
 1.1  04-Jul-1995  paulus Latest version of PPP stuff, with packet compression and other
improvements. The PPP kernel code is now split into if_ppp.c,
containing generic PPP support, and ppp_tty.c, which specifically
supports PPP on async tty devices (as a line discipline). This is
so that other devices can be supported without making them look
like ttys.
 1.14.4.1  11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.15.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.18.2.5  21-Apr-2001  bouyer Sync with HEAD
 1.18.2.4  11-Feb-2001  bouyer Sync with HEAD.
 1.18.2.3  13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.18.2.2  22-Nov-2000  bouyer Sync with HEAD.
 1.18.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.23.2.9  17-Sep-2002  nathanw Catch up to -current.
 1.23.2.8  01-Aug-2002  nathanw Catch up to -current.
 1.23.2.7  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.23.2.6  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.23.2.5  14-Nov-2001  nathanw Catch up to -current.
 1.23.2.4  24-Aug-2001  nathanw Catch up with -current.
 1.23.2.3  21-Jun-2001  nathanw Catch up to -current.
 1.23.2.2  09-Apr-2001  nathanw Catch up with -current.
 1.23.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.25.2.6  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.25.2.5  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.25.2.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.25.2.3  16-Mar-2002  jdolecek Catch up with -current.
 1.25.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.25.2.1  03-Aug-2001  lukem update to -current
 1.26.2.2  13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.26.2.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.30.4.2  15-Jul-2002  gehenna catch up with -current.
 1.30.4.1  16-May-2002  gehenna Add the character device switch.
Replace the direct-access to devsw table with calling devsw APIs.
 1.33.2.6  11-Dec-2005  christos Sync with head.
 1.33.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.33.2.4  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.33.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.33.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.33.2.1  03-Aug-2004  skrll Sync with HEAD
 1.34.10.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.34.8.1  29-Apr-2005  kent sync with -current
 1.38.8.1  29-Nov-2005  yamt sync with head.
 1.38.2.7  27-Feb-2008  yamt sync with head.
 1.38.2.6  07-Dec-2007  yamt sync with head
 1.38.2.5  15-Nov-2007  yamt sync with head.
 1.38.2.4  03-Sep-2007  yamt sync with head.
 1.38.2.3  26-Feb-2007  yamt sync with head.
 1.38.2.2  30-Dec-2006  yamt sync with head.
 1.38.2.1  21-Jun-2006  yamt sync with head.
 1.41.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.41.10.3  06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.41.10.2  10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.41.10.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.41.8.2  11-Aug-2006  yamt sync with head
 1.41.8.1  24-May-2006  yamt sync with head.
 1.41.6.1  01-Jun-2006  kardel Sync with head.
 1.41.4.1  09-Sep-2006  rpaulo sync with head
 1.43.6.2  10-Dec-2006  yamt sync with head.
 1.43.6.1  22-Oct-2006  yamt sync with head
 1.43.4.2  12-Jan-2007  ad Sync with head.
 1.43.4.1  18-Nov-2006  ad Sync with head.
 1.46.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.47.22.2  08-Dec-2007  mjf Sync with HEAD.
 1.47.22.1  19-Nov-2007  mjf Sync with HEAD.
 1.47.20.1  13-Nov-2007  bouyer Sync with HEAD
 1.47.16.3  23-Mar-2008  matt sync with HEAD
 1.47.16.2  09-Jan-2008  matt sync with HEAD
 1.47.16.1  08-Nov-2007  matt sync with -HEAD
 1.47.14.3  03-Dec-2007  joerg Sync with HEAD.
 1.47.14.2  14-Nov-2007  joerg Sync with HEAD.
 1.47.14.1  11-Nov-2007  joerg Sync with HEAD.
 1.47.2.2  23-Oct-2007  ad Sync with head.
 1.47.2.1  05-Apr-2007  ad Compile fixes.
 1.52.12.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.52.10.4  11-Aug-2010  yamt sync with head.
 1.52.10.3  11-Mar-2010  yamt sync with head
 1.52.10.2  16-May-2009  yamt sync with head
 1.52.10.1  04-May-2009  yamt sync with head.
 1.52.8.1  04-Jun-2008  yamt sync with head
 1.52.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.53.12.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.6.1  28-Apr-2009  skrll Sync with HEAD.
 1.56.4.1  30-May-2010  rmind sync with head
 1.56.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.57.32.1  10-Aug-2014  tls Rebase.
 1.57.18.2  03-Dec-2017  jdolecek update from HEAD
 1.57.18.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.58.4.3  05-Oct-2016  skrll Sync with HEAD
 1.58.4.2  09-Jul-2016  skrll Sync with HEAD
 1.58.4.1  22-Sep-2015  skrll Sync with HEAD
 1.61.2.2  04-Nov-2016  pgoyette Sync with HEAD
 1.61.2.1  20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.63.8.1  29-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1727):

sys/net/ppp_tty.c: revision 1.68
sys/net/ppp_tty.c: revision 1.69

Use unsigned to avoid undefined behavior in pppasyncstart().

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.63.6.1  27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.64.4.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.64.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.64.4.1  10-Jun-2019  christos Sync with HEAD
 1.64.2.1  26-Jan-2019  pgoyette Sync with HEAD
 1.65.4.1  29-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1411):

sys/net/ppp_tty.c: revision 1.68
sys/net/ppp_tty.c: revision 1.69

Use unsigned to avoid undefined behavior in pppasyncstart().

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.66.2.1  29-Feb-2020  ad Sync with head.
 1.71.2.1  21-Dec-2022  martin Pull up following revision(s) (requested by chs in ticket #19):

external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc: revision 1.5
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h: revision 1.8
sys/sys/ttycom.h: revision 1.22
sys/net/ppp_tty.c: revision 1.72
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc: revision 1.9

ppp: remove ioctls that never worked and crash the kernel

Remove vestigial bits of PPP HDLC support that never worked on netbsd.

The TIOCRCVFRAME ioctl was apparently intended to be called only from
within the kernel, but nothing prevents user code from calling this ioctl
and crashing the kernel.

RSS XML Feed