From f44004690ccdaef0a3995cf1664796127e0fe222 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Tue, 4 Nov 2003 01:14:58 +0000 Subject: [PATCH] Do not attempt to report proc event if NOTE_EXIT has already been received. This fixes a race condition (specifically with signal events) that could lead to the kn being re-inserted into the list after it has been destroyed, which is not something we want to happen. PR: kern/58258 --- sys/kern/kern_event.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index a9e42deed374..85ee24e46efb 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -279,6 +279,13 @@ filt_proc(struct knote *kn, long hint) return (1); } + /* + * Process will already be reported as gone. + * Do not report anything else, as the knote will be destroyed soon. + */ + if (kn->kn_status & KN_DETACHED) + return (0); + /* * process forked, and user wants to track the new process, * so attach a new knote to it, and immediately report an