* [PATCH v2] seccomp: Use wq_has_sleeper() when an unused filter wakes its waiters
@ 2026-11-29 12:52 Zhenwen Liang
0 siblings, 0 replies; only message in thread
From: Zhenwen Liang @ 2026-11-29 12:52 UTC (permalink / raw)
To: Kees Cook
Cc: Andy Lutomirski, Will Drewry, Christian Brauner, Andrei Vagin,
linux-kernel, Bradley Morgan
__seccomp_filter_orphan() checks waitqueue_active() after
refcount_dec_and_test(), which is not a full barrier, so a waiter in
recv_wait_event() or seccomp_notify_poll() can read the old users count
while the waker sees an empty queue. The wakeup is then lost and
SECCOMP_IOCTL_NOTIF_RECV or poll() keeps sleeping. Use wq_has_sleeper(),
which issues the smp_mb() the waker needs.
The problem was found, and this patch prepared, with the help of a
formal analysis tool we are developing that uses AI assistance; I have
reviewed the analysis and the patch.
Fixes: 99cdb8b9a573 ("seccomp: notify about unused filter")
Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>
Signed-off-by: Zhenwen Liang <zhenwenliang@google.com>
---
v2: Shorten the changelog (Bradley Morgan). No code change.
v1: https://lore.kernel.org/r/20261129024631.271472-1-zhenwenliang@google.com/
kernel/seccomp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 3eecba5ccdef..1f48bfdb3076 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -534,7 +534,7 @@ static inline void seccomp_filter_free(struct seccomp_filter *filter)
static void __seccomp_filter_orphan(struct seccomp_filter *orig)
{
while (orig && refcount_dec_and_test(&orig->users)) {
- if (waitqueue_active(&orig->wqh))
+ if (wq_has_sleeper(&orig->wqh))
wake_up_poll(&orig->wqh, EPOLLHUP);
orig = orig->prev;
}
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-29 12:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 12:52 [PATCH v2] seccomp: Use wq_has_sleeper() when an unused filter wakes its waiters Zhenwen Liang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®