freebsd-src/sys/net
Christian S.J. Peron 93e39f0b93 Introduce two new ioctl(2) commands, BIOCLOCK and BIOCSETWF. These commands
enhance the security of bpf(4) by further relinquishing the privilege of
the bpf(4) consumer (assuming the ioctl commands are being implemented).

Once BIOCLOCK is executed, the device becomes locked which prevents the
execution of ioctl(2) commands which can change the underly parameters of the
bpf(4) device. An example might be the setting of bpf(4) filter programs or
attaching to different network interfaces.

BIOCSETWF can be used to set write filters for outgoing packets. Currently if
a bpf(4) consumer is compromised, the bpf(4) descriptor can essentially be used
as a raw socket, regardless of consumer's UID. Write filters give users the
ability to constrain which packets can be sent through the bpf(4) descriptor.

These features are currently implemented by a couple programs which came from
OpenBSD, such as the new dhclient and pflogd.

-Modify bpf_setf(9) to accept a "cmd" parameter. This will be used to specify
 whether a read or write filter is to be set.
-Add a bpf(4) filter program as a parameter to bpf_movein(9) as we will run the
 filter program on the mbuf data once we move the packet in from user-space.
-Rather than execute two uiomove operations, (one for the link header and the
 other for the packet data), execute one and manually copy the linker header
 into the sockaddr structure via bcopy.
-Restructure bpf_setf to compensate for write filters, as well as read.
-Adjust bpf(4) stats structures to include a bd_locked member.

It should be noted that the FreeBSD and OpenBSD implementations differ a bit in
the sense that we unconditionally enforce the lock, where OpenBSD enforces it
only if the calling credential is not root.

Idea from:	OpenBSD
Reviewed by:	mlaier
2005-08-22 19:35:48 +00:00
..
bpf.c Introduce two new ioctl(2) commands, BIOCLOCK and BIOCSETWF. These commands 2005-08-22 19:35:48 +00:00
bpf.h Introduce two new ioctl(2) commands, BIOCLOCK and BIOCSETWF. These commands 2005-08-22 19:35:48 +00:00
bpf_compat.h Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00
bpf_filter.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
bpfdesc.h Introduce two new ioctl(2) commands, BIOCLOCK and BIOCSETWF. These commands 2005-08-22 19:35:48 +00:00
bridge.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
bridge.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
bridgestp.c Mark the callouts as MPSAFE as if_bridge has been giant-free since day 1. 2005-08-18 20:17:00 +00:00
bsd_comp.c Eliminate MAC entry point mac_create_mbuf_from_mbuf(), which is 2005-07-05 23:39:51 +00:00
ethernet.h add ETHERTYPE_PAE for EAPOL/802.1x 2004-10-05 19:28:52 +00:00
fddi.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
firewire.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if.c When we started calling if_findindex() from if_alloc() with an empty 2005-08-18 18:36:40 +00:00
if.h For each interface flag, indicate whether or not it is owned by the 2005-08-09 12:56:20 +00:00
if_arc.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_arcsubr.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_arp.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_atm.h Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_atmsubr.c o Make rt_check() function more strict: 2005-08-11 08:14:53 +00:00
if_bridge.c Mark the callouts as MPSAFE as if_bridge has been giant-free since day 1. 2005-08-18 20:17:00 +00:00
if_bridgevar.h - Previously when broadcasting to N number of interfaces we would run pfil 2005-07-06 01:24:45 +00:00
if_clone.c o Move ifcr_count sanity check up and reject negative values before we 2005-02-24 13:14:41 +00:00
if_clone.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_disc.c Fix some long standing bugs in writing to the BPF device attached to 2005-06-26 18:11:11 +00:00
if_dl.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_ef.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_ethersubr.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_faith.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_fddisubr.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_fwsubr.c o Make rt_check() function more strict: 2005-08-11 08:14:53 +00:00
if_gif.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_gif.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_gre.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_gre.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_iso88025subr.c o Make rt_check() function more strict: 2005-08-11 08:14:53 +00:00
if_llc.h Add hooks into the networking layer to support if_bridge. This changes struct 2005-06-05 03:13:13 +00:00
if_loop.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_media.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_media.h Add CARP (Common Address Redundancy Protocol), which allows multiple 2005-02-22 13:04:05 +00:00
if_mib.c If we are going to 2005-05-06 02:50:00 +00:00
if_mib.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_ppp.c Axe ppp_for_tty(). Use tty->t_lsc pointer to store sc. This 2005-08-12 08:27:15 +00:00
if_ppp.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_pppvar.h Axe ppp_for_tty(). Use tty->t_lsc pointer to store sc. This 2005-08-12 08:27:15 +00:00
if_sl.c Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_slvar.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_sppp.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_spppfr.c Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_spppsubr.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_stf.c Fix some long standing bugs in writing to the BPF device attached to 2005-06-26 18:11:11 +00:00
if_stf.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_tap.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_tap.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_tapvar.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_tun.c Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
if_tun.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_types.h Stop embedding struct ifnet at the top of driver softcs. Instead the 2005-06-10 16:49:24 +00:00
if_var.h Rename IFF_RUNNING to IFF_DRV_RUNNING, IFF_OACTIVE to IFF_DRV_OACTIVE, 2005-08-09 10:16:17 +00:00
if_vlan.c Vlan interfaces change their type after ether_ifattach() so we needs to 2005-08-15 20:27:34 +00:00
if_vlan_var.h Allocate the M_VLANTAG m_pkthdr flag, and use it to indicate that 2005-02-18 22:31:19 +00:00
iso88025.h Add #defines for control fields and address bits. 2005-04-13 08:14:14 +00:00
net_osdep.h we are not OLD_BPF system. 2005-01-11 07:08:15 +00:00
netisr.c Correctly unregister a netisr by clearing the ni->ni_queue field to NULL as 2004-10-11 20:01:43 +00:00
netisr.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
pfil.c Fix semantics of ph_busy_count == -1 to pass instead of block. 2005-05-23 17:07:16 +00:00
pfil.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
pfkeyv2.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ppp_comp.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ppp_deflate.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ppp_defs.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ppp_tty.c Axe ppp_for_tty(). Use tty->t_lsc pointer to store sc. This 2005-08-12 08:27:15 +00:00
radix.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
radix.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
raw_cb.c Acquire the raw_cb mutex around LIST_REMOVE() of a raw socket control 2005-01-24 22:56:09 +00:00
raw_cb.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
raw_usrreq.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
route.c o Make rt_check() function more strict: 2005-08-11 08:14:53 +00:00
route.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
rtsock.c o To prevent a race between RTM_DELETE message and 2005-08-11 08:26:31 +00:00
slcompress.c Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00
slcompress.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
slip.h Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00
zlib.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
zlib.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00