summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorcsjp <csjp@FreeBSD.org>2005-10-04 15:06:10 +0000
committercsjp <csjp@FreeBSD.org>2005-10-04 15:06:10 +0000
commit369f8288e0ca10fee58a73a700c15c46cda1794c (patch)
tree0e6e62a624dce33869866438f183bbaf6482f09d /sys/net
parent0b891ae48d7ae6ffe1eb8f128a7eba64b3a50d65 (diff)
downloadFreeBSD-src-369f8288e0ca10fee58a73a700c15c46cda1794c.zip
FreeBSD-src-369f8288e0ca10fee58a73a700c15c46cda1794c.tar.gz
Protect PID initializations for statistics by the bpf descriptor
locks. Also while we are here, protect the bpf descriptor during knlist_remove{add} operations. Discussed with: rwatson
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bpf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 659410d..d2c2d51 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -696,8 +696,8 @@ bpfioctl(dev, cmd, addr, flags, td)
/*
* Refresh PID associated with this descriptor.
*/
- d->bd_pid = td->td_proc->p_pid;
BPFD_LOCK(d);
+ d->bd_pid = td->td_proc->p_pid;
if (d->bd_state == BPF_WAITING)
callout_stop(&d->bd_callout);
d->bd_state = BPF_IDLE;
@@ -1147,9 +1147,9 @@ bpfpoll(dev, events, td)
/*
* Refresh PID associated with this descriptor.
*/
- d->bd_pid = td->td_proc->p_pid;
revents = events & (POLLOUT | POLLWRNORM);
BPFD_LOCK(d);
+ d->bd_pid = td->td_proc->p_pid;
if (events & (POLLIN | POLLRDNORM)) {
if (bpf_ready(d))
revents |= events & (POLLIN | POLLRDNORM);
@@ -1184,10 +1184,12 @@ bpfkqfilter(dev, kn)
/*
* Refresh PID associated with this descriptor.
*/
+ BPFD_LOCK(d);
d->bd_pid = curthread->td_proc->p_pid;
kn->kn_fop = &bpfread_filtops;
kn->kn_hook = d;
knlist_add(&d->bd_sel.si_note, kn, 0);
+ BPFD_UNLOCK(d);
return (0);
}
@@ -1198,7 +1200,9 @@ filt_bpfdetach(kn)
{
struct bpf_d *d = (struct bpf_d *)kn->kn_hook;
+ BPFD_LOCK(d);
knlist_remove(&d->bd_sel.si_note, kn, 0);
+ BPFD_UNLOCK(d);
}
static int
OpenPOWER on IntegriCloud