summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf.h
diff options
context:
space:
mode:
authorghelmer <ghelmer@FreeBSD.org>2012-12-10 16:14:44 +0000
committerghelmer <ghelmer@FreeBSD.org>2012-12-10 16:14:44 +0000
commit726beb3d43000997e7410621a0c31a65b05ebb31 (patch)
tree05f79a3e8fd1361998dd0dc02f1088df035c8960 /sys/net/bpf.h
parent2160ff58527c3253bc5fe11f85c2e3d0fa680688 (diff)
downloadFreeBSD-src-726beb3d43000997e7410621a0c31a65b05ebb31.zip
FreeBSD-src-726beb3d43000997e7410621a0c31a65b05ebb31.tar.gz
Changes to resolve races in bpfread() and catchpacket() that, at worst,
cause kernel panics. Add a flag to the bpf descriptor to indicate whether the hold buffer is in use. In bpfread(), set the "hold buffer in use" flag before dropping the descriptor lock during the call to bpf_uiomove(). Everywhere else the hold buffer is used or changed, wait while the hold buffer is in use by bpfread(). Add a KASSERT in bpfread() after re-acquiring the descriptor lock to assist uncovering any additional hold buffer races.
Diffstat (limited to 'sys/net/bpf.h')
-rw-r--r--sys/net/bpf.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index a778ce6..e362f16 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -1235,7 +1235,8 @@ SYSCTL_DECL(_net_bpf);
/*
* Rotate the packet buffers in descriptor d. Move the store buffer into the
* hold slot, and the free buffer ino the store slot. Zero the length of the
- * new store buffer. Descriptor lock should be held.
+ * new store buffer. Descriptor lock should be held. Hold buffer must
+ * not be marked "in use".
*/
#define ROTATE_BUFFERS(d) do { \
(d)->bd_hbuf = (d)->bd_sbuf; \
OpenPOWER on IntegriCloud