diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2018-08-15 13:19:07 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2018-08-15 13:19:07 +0000 |
commit | 00ca866c8d7d752547384f7c27a658cf868cbfcf (patch) | |
tree | 32a44cdfc4fae926f904cbd053a0b28a61b1e7d8 /sys/kern/kern_event.c | |
parent | c4bbae0b494d3b137403b7ba558fb2ce3922740b (diff) |
Grab the KERNEL_LOCK() in MP-unsafe fo_close routines. This prevents
a scenario where MP-unsafe code gets run without the kernel lock
as a consequence of an unlocked system call.
OK mpi@, kettenis@
Diffstat (limited to 'sys/kern/kern_event.c')
-rw-r--r-- | sys/kern/kern_event.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index c141f2ac729..4556569063f 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_event.c,v 1.96 2018/08/09 15:02:45 visa Exp $ */ +/* $OpenBSD: kern_event.c,v 1.97 2018/08/15 13:19:06 visa Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -905,6 +905,8 @@ kqueue_close(struct file *fp, struct proc *p) struct kqueue *kq = fp->f_data; int i; + KERNEL_LOCK(); + for (i = 0; i < kq->kq_knlistsize; i++) knote_remove(p, &kq->kq_knlist[i]); if (kq->kq_knhashmask != 0) { @@ -917,6 +919,8 @@ kqueue_close(struct file *fp, struct proc *p) kqueue_wakeup(kq); KQRELE(kq); + KERNEL_UNLOCK(); + return (0); } |