1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

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
This commit is contained in:
Christian S.J. Peron 2005-10-04 15:06:10 +00:00
parent 3f9b405c78
commit cb1d4f92ec
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=150929

View File

@ -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