Home | History | Annotate | Download | only in common
History log of /src/sys/compat/common/uipc_syscalls_40.c
RevisionDateAuthorComments
 1.24  07-Jul-2022  riastradh ifioctl(9): Don't touch ifconf or ifreq until command is validated.

sys_ioctl validates the data pointer according to the command's size
and direction. But userland may ioctl commands other than
OSIOCGIFCONF or OOSIOCGIFCONF -- and if userland passes an IOC_VOID
command, the argument is passed through verbatim and may be null.

Reported-by: syzbot+19b1bf83e5481273eafc@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=f4c91a7dcd31901c80d91af6ed01456faf0a7286

Reported-by: syzbot+442c033feb784d055185@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=4a3a4b92dbe9695046ff17a5474cef52aed23e0b

Reported-by: syzbot+4c87d0cdf7025741ea7a@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=3e5f42c998e43ad42da40dec3c7873e6aae187e4
 1.23  16-Jul-2020  msaitoh Don't accept negative value.

Reported-by: syzbot+e71a77402d6668f1868d@syzkaller.appspotmail.com
 1.22  22-Feb-2020  maxv pass the address of the field, instead of relying on it being the first
field of the structure, no functional change
 1.21  12-Dec-2019  pgoyette branches: 1.21.2;
Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.20  23-Apr-2019  msaitoh branches: 1.20.2;
KNF. No functional change.
 1.19  18-Apr-2019  christos Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.18  01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.17  27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.16  12-Apr-2018  christos branches: 1.16.2;
provide vectors for the ifconf compat code and ifdatareq compat code.
 1.15  22-Nov-2017  martin branches: 1.15.2;
#idef the label next_ifa: just like the only goto using it.
 1.14  22-Nov-2017  ozaki-r Fix and make consistent of usages of psz/psref in ifconf variants
 1.13  14-Mar-2017  ozaki-r branches: 1.13.6;
Use if_acquire and if_release instead of using psref API directly

- Provide if_release for consistency to if_acquire
- Use if_acquire and if_release for ifp iterations
- Make ifnet_psref_class static
 1.12  01-Aug-2016  ozaki-r branches: 1.12.2;
Apply pserialize and psref to struct ifaddr and its variants

This change makes struct ifaddr and its variants (in_ifaddr and in6_ifaddr)
MP-safe by using pserialize and psref. At this moment, pserialize_perform
and psref_target_destroy are disabled because (1) we don't need them
because of softnet_lock (2) they cause a deadlock because of softnet_lock.
So we'll enable them when we remove softnet_lock in the future.
 1.11  07-Jul-2016  ozaki-r branches: 1.11.2;
Switch the address list of intefaces to pslist(9)

As usual, we leave the old list to avoid breaking kvm(3) users.
 1.10  16-Jun-2016  ozaki-r Use curlwp_bind and curlwp_bindx instead of open-coding LP_BOUND
 1.9  12-May-2016  ozaki-r Protect ifnet list with psz and psref

The change ensures that ifnet objects in the ifnet list aren't freed during
list iterations by using pserialize(9) and psref(9).

Note that the change adds a pslist(9) for ifnet but doesn't remove the
original ifnet list (ifnet_list) to avoid breaking kvm(3) users. We
shouldn't use the original list in the kernel anymore.
 1.8  26-Nov-2014  ozaki-r branches: 1.8.2;
Tweak ifconf variants

The tweaks make the code intention clear and make further changes easy.

No functional change.
 1.7  19-Jan-2011  tsutsui branches: 1.7.16; 1.7.32; 1.7.34; 1.7.38;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.6  05-Dec-2007  dyoung branches: 1.6.38; 1.6.44;
Use IFADDR_EMPTY().
 1.5  05-Dec-2007  dyoung Use IFADDR_FOREACH().
 1.4  02-Jun-2007  enami branches: 1.4.2; 1.4.4; 1.4.10; 1.4.12; 1.4.14; 1.4.20; 1.4.22;
Reduce difference between compat_ifconf() and ifconf():
- exit on error rather than proceeding to next interface.
- make code simpler.
 1.3  30-May-2007  christos Move the nasty ifdefs in one place. Requested by ad and dyoung.
 1.2  29-May-2007  christos wrap the whole function in COMPAT_40
 1.1  29-May-2007  christos Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
 1.4.22.1  08-Dec-2007  ad Sync with head.
 1.4.20.1  08-Dec-2007  mjf Sync with HEAD.
 1.4.14.3  07-Dec-2007  yamt sync with head
 1.4.14.2  03-Sep-2007  yamt sync with head.
 1.4.14.1  02-Jun-2007  yamt file uipc_syscalls_40.c was added on branch yamt-lazymbuf on 2007-09-03 14:31:52 +0000
 1.4.12.1  09-Jan-2008  matt sync with HEAD
 1.4.10.1  09-Dec-2007  jmcneill Sync with HEAD.
 1.4.4.2  11-Jul-2007  mjf Sync with head.
 1.4.4.1  02-Jun-2007  mjf file uipc_syscalls_40.c was added on branch mjf-ufs-trans on 2007-07-11 20:03:49 +0000
 1.4.2.3  09-Jun-2007  ad Sync with head.
 1.4.2.2  09-Jun-2007  ad Sync with head.
 1.4.2.1  02-Jun-2007  ad file uipc_syscalls_40.c was added on branch vmlocking on 2007-06-09 21:37:08 +0000
 1.6.44.1  06-Jun-2011  jruoho Sync with HEAD.
 1.6.38.1  05-Mar-2011  rmind sync with head
 1.7.38.1  19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.7.34.1  19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.7.32.1  19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.7.16.1  03-Dec-2017  jdolecek update from HEAD
 1.8.2.4  28-Aug-2017  skrll Sync with HEAD
 1.8.2.3  05-Oct-2016  skrll Sync with HEAD
 1.8.2.2  09-Jul-2016  skrll Sync with HEAD
 1.8.2.1  29-May-2016  skrll Sync with HEAD
 1.11.2.2  20-Mar-2017  pgoyette Sync with HEAD
 1.11.2.1  06-Aug-2016  pgoyette Sync with HEAD
 1.12.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.13.6.4  17-Jul-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1576):

sys/net/if.c: revision 1.479
sys/compat/common/uipc_syscalls_40.c: revision 1.23
sys/compat/linux/common/linux_socket.c: revision 1.150
sys/compat/linux32/common/linux32_socket.c: revision 1.31

Don't accept negative value.
 1.13.6.3  19-Apr-2019  martin Pull up following revision(s) (requested by christos in ticket #1233):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.13.6.2  04-Dec-2017  martin Additionaly pull up rev 1.15 for ticket #407, requested by ozaki-r:
#idef the label next_ifa: just like the only goto using it.
 1.13.6.1  30-Nov-2017  martin Pull up following revision(s) (requested by ozaki-r in ticket #407):
sys/compat/linux32/common/linux32_socket.c: revision 1.28
sys/net/if.c: revision 1.400
sys/netipsec/key.c: revision 1.243
sys/compat/linux/common/linux_socket.c: revision 1.139
sys/netinet/ip_carp.c: revision 1.93
sys/netinet6/in6.c: revision 1.252
sys/netinet6/in6.c: revision 1.253
sys/netinet6/in6.c: revision 1.254
sys/net/if_spppsubr.c: revision 1.173
sys/net/if_spppsubr.c: revision 1.174
sys/compat/common/uipc_syscalls_40.c: revision 1.14
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Fix usage of FOREACH macro
key_sad.lock is held there so SAVLIST_WRITER_FOREACH is enough.
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref (more)
Fix and make consistent of usages of psz/psref in ifconf variants
Remove unnecessary goto because there is no cleanup code to share (NFC)
Tweak a condition; we don't need to care ifacount to be negative
Fix a race condition of in6_ifinit
in6_ifinit checks the number of IPv6 addresses on a given interface and
if it's zero (i.e., an IPv6 address being assigned to the interface
is the first one), call if_addr_init. However, the actual assignment of
the address (ifa_insert) is out of in6_ifinit. The check and the
assignment must be done atomically.
Fix it by holding in6_ifaddr_lock during in6_ifinit and ifa_insert.
And also add missing pserialize to IFADDR_READER_FOREACH.
 1.15.2.13  23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.15.2.12  15-Oct-2018  pgoyette Convert a couple more hooks to the MP-safe mechanism.

While here, clean up some headers and remove any that are now empty.
 1.15.2.11  22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.15.2.10  20-Sep-2018  pgoyette Use the MP-safe hooks mechanism for the uipc_syscalls_40 and _50
routines.
 1.15.2.9  16-Apr-2018  pgoyette Rename if_[45]0_{init,fini} entry points to more appropriate and more
consistent uipc_syscalls_[45]0_{init,fini} and remove some multiple
declarations.
 1.15.2.8  16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.15.2.7  15-Apr-2018  pgoyette Make compat_ifconf() and compat_ifdatareq() static
 1.15.2.6  12-Apr-2018  pgoyette Merge christos's recent changes on HEAD
 1.15.2.5  08-Mar-2018  pgoyette Remove unnecessary conditionals. These files aren't built unless
their content is needed (via config option or module configuration).
 1.15.2.4  08-Mar-2018  pgoyette Handle ifconf() compat vectors
 1.15.2.3  06-Mar-2018  pgoyette Use a .h file for declaring the if_40_{init, fini} routines
 1.15.2.2  06-Mar-2018  pgoyette Typo in function declaration.
 1.15.2.1  06-Mar-2018  pgoyette Untangle some networking compat code so we can build a kernel with
networking and MODULAR, but without any actual COMPAT_* code (ie,
assuming that all the compat stuff can be added later via modules).
 1.16.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.16.2.1  10-Jun-2019  christos Sync with HEAD
 1.20.2.1  17-Jul-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1018):

sys/net/if.c: revision 1.479
sys/compat/common/uipc_syscalls_40.c: revision 1.23
sys/compat/linux/common/linux_socket.c: revision 1.150
sys/compat/linux32/common/linux32_socket.c: revision 1.31

Don't accept negative value.
 1.21.2.1  29-Feb-2020  ad Sync with head.

RSS XML Feed