diff options
| author | 2020-06-15 13:18:33 +0000 | |
|---|---|---|
| committer | 2020-06-15 13:18:33 +0000 | |
| commit | 98a52fa9d4636ee9d7e5d0a09e38aef03246795f (patch) | |
| tree | 297c492ea75fe6924aa69de7b62fc4a0024d33e2 /sys/kern/kern_event.c | |
| parent | print the name of the rings in systat mbuf output too. (diff) | |
| download | wireguard-openbsd-98a52fa9d4636ee9d7e5d0a09e38aef03246795f.tar.xz wireguard-openbsd-98a52fa9d4636ee9d7e5d0a09e38aef03246795f.zip | |
Raise SPL when modifying ps_klist to prevent a race with interrupts.
The list can be accessed from interrupt context if a signal is sent
from an interrupt handler.
OK anton@ cheloha@ mpi@
Diffstat (limited to 'sys/kern/kern_event.c')
| -rw-r--r-- | sys/kern/kern_event.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index bb1340da842..ac793bd2045 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_event.c,v 1.137 2020/06/14 07:22:55 visa Exp $ */ +/* $OpenBSD: kern_event.c,v 1.138 2020/06/15 13:18:33 visa Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -246,6 +246,7 @@ int filt_procattach(struct knote *kn) { struct process *pr; + int s; if ((curproc->p_p->ps_flags & PS_PLEDGE) && (curproc->p_p->ps_pledge & PLEDGE_PROC) == 0) @@ -274,7 +275,9 @@ filt_procattach(struct knote *kn) kn->kn_flags &= ~EV_FLAG1; } + s = splhigh(); klist_insert(&pr->ps_klist, kn); + splx(s); return (0); } @@ -291,11 +294,14 @@ void filt_procdetach(struct knote *kn) { struct process *pr = kn->kn_ptr.p_process; + int s; if (kn->kn_status & KN_DETACHED) return; + s = splhigh(); klist_remove(&pr->ps_klist, kn); + splx(s); } int @@ -324,10 +330,10 @@ filt_proc(struct knote *kn, long hint) s = splhigh(); kn->kn_status |= KN_DETACHED; - splx(s); kn->kn_flags |= (EV_EOF | EV_ONESHOT); kn->kn_data = W_EXITCODE(pr->ps_xexit, pr->ps_xsig); klist_remove(&pr->ps_klist, kn); + splx(s); return (1); } |
