From: Andrea Parri <parri.andrea@gmail.com>
To: Kees Cook <kees@kernel.org>
Cc: Andrea Parri <parri.andrea@gmail.com>,
Andy Lutomirski <luto@amacapital.net>,
Will Drewry <wad@chromium.org>, Shuah Khan <shuah@kernel.org>,
Rodrigo Campos <rodrigo@kinvolk.io>,
Christian Brauner <brauner@kernel.org>,
Tycho Andersen <tycho@tycho.pizza>,
Sargun Dhillon <sargun@sargun.me>, Hui Peng <benquike@gmail.com>,
Bradley Morgan <brads@mainlining.org>,
Cong Wang <cwang@multikernel.io>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
bpf@vger.kernel.org
Subject: [PATCH 0/4] seccomp: fix user-notification state transitions
Date: Wed, 4 Nov 2026 11:37:30 +0100 [thread overview]
Message-ID: <20261104103736.71956-1-parri.andrea@gmail.com> (raw)
An atomic SECCOMP_IOCTL_NOTIF_ADDFD request moves a notification from
SENT to REPLIED, so the listener stops reporting EPOLLOUT for it. Two
paths move it back to SENT without waking poll waiters, so a supervisor
waiting for EPOLLOUT, with edge- or level-triggered epoll, poll() or
select(), can remain asleep, leaving the target blocked in the trapped
syscall.
Patch 1 fixes the failed descriptor install, present since commit
0ae71c7720e3a ("seccomp: Support atomic "addfd + send reply""). Patch 2
fixes the restore on signal interruption, added by
commit 832b9b176be06 ("seccomp: restore knotif->state when
SECCOMP_ADDFD_FLAG_SEND is interrupted"). Patch 3 moves the state change
and the wakeup into one helper, with no functional change.
SECCOMP_IOCTL_NOTIF_RECV marks a notification SENT before copying it to
userspace. Unless SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV is also set, a
signal during the copy makes the target return EINTR, even with
SECCOMP_FILTER_FLAG_RESTART_BEFORE_RECV, while the supervisor can receive
a withdrawn ID. With it, the signal is held back as if the notification
had already been received. Patch 4 adds a RECEIVING state and marks the
notification SENT only after the copy.
Patch 4 affects all filters, not only those using RESTART_BEFORE_RECV:
RECV now fails with ENOENT if the target withdraws the notification during
the copy. It clears the buffer first, and
Documentation/userspace-api/seccomp_filter.rst already asks supervisors to
retry on ENOENT.
All four patches concern transitions into SENT; patch 4 takes its
post-copy transition through the helper added by patch 3.
Tested in vng on x86_64 with the full seccomp_bpf suite, using the seccomp
selftest config plus CHECKPOINT_RESTORE: 146 passed, 0 failed, 0 skipped.
Reverting the kernel/seccomp.c changes of the whole series makes
user_notification_addfd_rlimit and user_notification_addfd_send_interrupted
time out on their second epoll_wait() and all four during_receive variants
fail; reverting only those of patch 4 makes just the during_receive
variants fail.
The bugs were found and the patches were written with the help of an LLM.
---
Reviewer notes: 832b9b176be06 and f7952251ecc3, fixed by patches 2 and 4,
are in v7.4-rc1. Patches 3 and 4 only need backporting to 7.4.x:
f7952251ecc3 adds a new flag that is not tagged for stable itself,
unlike 832b9b176be06, and patch 3 is tagged only because patch 4 needs
it.
Patches 1 and 2 do not depend on patches 3 and 4 and can be applied
first.
The series conflicts with Cong Wang's RFC "seccomp: report the result of
continued system calls" [1], which is based on v7.3. After patch 4, a
task killed while its held notification is being received is in
RECEIVING, so the "killed unseen" check in seccomp_hold_result() would
need to become n.state <= SECCOMP_NOTIFY_RECEIVING for the result to
still be queued.
[1] https://lore.kernel.org/all/20261020001124.974063-1-xiyou.wangcong@gmail.com/
Andrea Parri (4):
seccomp: wake poll waiters after failed addfd send
seccomp: wake poll waiters after interrupted addfd send
seccomp: add a helper to move a notification to SENT
seccomp: publish user notifications after copying them to userspace
kernel/seccomp.c | 79 +++++----
tools/testing/selftests/seccomp/config | 1 +
tools/testing/selftests/seccomp/seccomp_bpf.c | 162 +++++++++++++++++-
3 files changed, 204 insertions(+), 38 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.53.0
next reply other threads:[~2026-11-04 10:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 10:37 Andrea Parri [this message]
2026-11-04 10:37 ` [PATCH 1/4] seccomp: wake poll waiters after failed addfd send Andrea Parri
2026-11-04 16:19 ` Tycho Andersen
2026-11-04 10:37 ` [PATCH 2/4] seccomp: wake poll waiters after interrupted " Andrea Parri
2026-11-04 10:37 ` [PATCH 3/4] seccomp: add a helper to move a notification to SENT Andrea Parri
2026-11-04 10:37 ` [PATCH 4/4] seccomp: publish user notifications after copying them to userspace Andrea Parri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104103736.71956-1-parri.andrea@gmail.com \
--to=parri.andrea@gmail.com \
--cc=benquike@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=brads@mainlining.org \
--cc=brauner@kernel.org \
--cc=cwang@multikernel.io \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=rodrigo@kinvolk.io \
--cc=sargun@sargun.me \
--cc=shuah@kernel.org \
--cc=tycho@tycho.pizza \
--cc=wad@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®