git: 4627fe9e5afc - main - kqueue: Fix delivery of unwanted events
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Jul 2026 06:06:40 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=4627fe9e5afc0dce4469f5964f5d4b0e49a24274
commit 4627fe9e5afc0dce4469f5964f5d4b0e49a24274
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-07-23 06:06:32 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-07-23 06:06:32 +0000
kqueue: Fix delivery of unwanted events
In both procdesc_kqops_event() and filt_proc(), the event variable can
have more than one bit set. This means that:
* We cannot compare it directly with NOTE_EXIT; we must binary-and them
instead.
* We cannot binary-or it with the report mask; we must binary-and it
with the request mask first.
MFC after: 1 week
Fixes: 2a5e58c59694 ("procdesc: add NOTE_PDSIGCHLD")
Fixes: b328975b9d7c ("procdesc: report NOTE_PDSIGCHLD for traced and stopped process")
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D58395
---
sys/kern/kern_event.c | 6 +++---
sys/kern/sys_procdesc.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index fa7f8bf7cdb7..e19415c8d443 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -529,11 +529,11 @@ filt_proc(struct knote *kn, long hint)
event = (u_int)hint & NOTE_PCTRLMASK;
/* If the user is interested in this event, record it. */
- if (kn->kn_sfflags & event)
- kn->kn_fflags |= event;
+ if ((kn->kn_sfflags & event) != 0)
+ kn->kn_fflags |= kn->kn_sfflags & event;
/* Process is gone, so flag the event as finished. */
- if (event == NOTE_EXIT) {
+ if ((event & NOTE_EXIT) != 0) {
kn->kn_flags |= EV_EOF | EV_ONESHOT;
kn->kn_ptr.p_proc = NULL;
if (kn->kn_fflags & NOTE_EXIT)
diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
index 94c2df4b1e69..7fc63256bc05 100644
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -518,8 +518,8 @@ procdesc_kqops_event(struct knote *kn, long hint)
}
/* If the user is interested in this event, record it. */
- if (kn->kn_sfflags & event)
- kn->kn_fflags |= event;
+ if ((kn->kn_sfflags & event) != 0)
+ kn->kn_fflags |= kn->kn_sfflags & event;
/* Process is gone, so flag the event as finished. */
if ((event & NOTE_EXIT) != 0) {