CVE-2026-138996: seccomp: restore knotif->state when SECCOMP_ADDFD_FLAG_SEND is interrupted
In the Linux kernel, the following vulnerability has been resolved:
seccomp: restore knotif->state when SECCOMPADDFDFLAGSEND is interrupted
In seccompnotifyaddfd(), when SECCOMPADDFDFLAGSEND is set in addfd.flags, knotif->state is optimistically transitioned from SECCOMPNOTIFYSENT to SECCOMPNOTIFYREPLIED before waking the tracee and waiting on kaddfd.completion:
if (addfd.flags & SECCOMPADDFDFLAGSEND) { knotif->state = SECCOMPNOTIFYREPLIED; ... }
If waitforcompletioninterruptible(&kaddfd.completion) is interrupted by a signal before the tracee dequeues the kaddfd request (!listempty(&kaddfd.list)), seccompnotifyaddfd() removes kaddfd from knotif->addfd and returns -EINTR to the supervisor without having installed the file descriptor.
However, knotif->state is left as SECCOMPNOTIFYREPLIED (with knotif->error == 0 and knotif->val == 0). This causes two problems:
1. When the tracee runs in dousernotif(), it checks if (knotif.state != SECCOMPNOTIFYREPLIED) after calling seccomphandleaddfd(). Because knotif->state is already SECCOMPNOTIFYREPLIED, the tracee exits the notification wait loop prematurely and returns 0 from the trapped syscall without the file descriptor ever having been installed.
2. If the supervisor retries SECCOMPIOCTLNOTIFADDFD or SECCOMPIOCTLNOTIFSEND before the tracee runs, it fails with -EINPROGRESS because knotif->state is no longer SECCOMPNOTIFYSENT.
Fix this by restoring knotif->state back to SECCOMPNOTIFYSENT if SECCOMPADDFDFLAGSEND was set and kaddfd was not consumed before the interrupted wait. Also add a seccompbpf selftest (usernotificationaddfdsendinterrupted) covering this race.
Tested in QEMU against Linux 7.3.0-rc3 using the usernotificationaddfdsendinterrupted selftest added in this patch (./seccompbpf -t usernotificationaddfdsendinterrupted): on the unfixed kernel the test fails because the retry ioctl(listener, SECCOMPIOCTLNOTIFADDFD, &addfd) returns -EINPROGRESS (-1) and the tracee prematurely exits dousernotif() with return value 0 instead of FD 42, whereas with this patch applied the test passes.