summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf.h
diff options
context:
space:
mode:
authorcsjp <csjp@FreeBSD.org>2005-08-22 19:35:48 +0000
committercsjp <csjp@FreeBSD.org>2005-08-22 19:35:48 +0000
commita41f7da35fb244fe048fbcc3b5c1f9bab176fb10 (patch)
tree9cbeb56763a05e4d72f4614d25bfc5038a8173c5 /sys/net/bpf.h
parent1fafbd1bb50e664ea2bb5c119df2e1779e16744e (diff)
downloadFreeBSD-src-a41f7da35fb244fe048fbcc3b5c1f9bab176fb10.zip
FreeBSD-src-a41f7da35fb244fe048fbcc3b5c1f9bab176fb10.tar.gz
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
Diffstat (limited to 'sys/net/bpf.h')
-rw-r--r--sys/net/bpf.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 7759b16..189b30f 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -113,6 +113,8 @@ struct bpf_version {
#define BIOCSSEESENT _IOW('B',119, u_int)
#define BIOCSDLT _IOW('B',120, u_int)
#define BIOCGDLTLIST _IOWR('B',121, struct bpf_dltlist)
+#define BIOCLOCK _IO('B', 122)
+#define BIOCSETWF _IOW('B',123, struct bpf_program)
/*
* Structure prepended to each packet.
OpenPOWER on IntegriCloud