diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2021-07-24 09:16:52 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2021-07-24 09:16:52 +0000 |
commit | 1a774db3cb6dd3ba1b218a3279bbaef9aa5f28ab (patch) | |
tree | aecbcd2c249e969388281c6dc1e56d7d7962ce42 | |
parent | 355a181f87e40a5e5fa65ee6cd9c5aebdd15bf03 (diff) |
Modifying a knote must be done with the corresponding lock held. Assert
that the KERNEL_LOCK() is held unless the filter is marked as MPSAFE.
Should help finding missing locks when unlocking various filters.
ok visa@
-rw-r--r-- | sys/kern/kern_event.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 370a8f6c592..030b20eba84 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_event.c,v 1.168 2021/07/22 07:22:43 visa Exp $ */ +/* $OpenBSD: kern_event.c,v 1.169 2021/07/24 09:16:51 mpi Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -1908,6 +1908,9 @@ knote_dequeue(struct knote *kn) void knote_modify(const struct kevent *kev, struct knote *kn) { + if ((kn->kn_fop->f_flags & FILTEROP_MPSAFE) == 0) + KERNEL_ASSERT_LOCKED(); + kn->kn_sfflags = kev->fflags; kn->kn_sdata = kev->data; kn->kn_udata = kev->udata; @@ -1921,6 +1924,9 @@ knote_modify(const struct kevent *kev, struct knote *kn) void knote_submit(struct knote *kn, struct kevent *kev) { + if ((kn->kn_fop->f_flags & FILTEROP_MPSAFE) == 0) + KERNEL_ASSERT_LOCKED(); + if (kev != NULL) { *kev = kn->kn_kevent; if (kn->kn_flags & EV_CLEAR) { |