From 7ab9343735febf44ccd0034b35ab25fee4d5c37e Mon Sep 17 00:00:00 2001 From: mpi Date: Sat, 24 Jul 2021 09:16:51 +0000 Subject: [PATCH] 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@ --- sys/kern/kern_event.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 @@ -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) { -- 2.20.1