seccomp: signals interrupt queued notifications, so trapped syscalls return EINTR (pipelines hang)
Three-stage shell pipelines hang about a third of the time:
sandlock run -r /usr -r /lib -r /lib64 -r /bin -r /etc -- sh -c 'echo abc | cat | cat'
strace of the shell shows close(5) = ? ERESTARTSYS when SIGCHLD from the first stage arrives. dash installs its handler without SA_RESTART, so it sees EINTR, and since sandlock intercepted the close(), it never ran. The pipe's write end leaks into the last stage, which never sees EOF. The same cause also shows up as dash printing "Cannot fork".
WAIT_KILLABLE_RECV only protects a notification after the supervisor has received it. The loop in seccomp/notif.rs receives one notification, awaits its handler, then receives the next, so everything queued behind it stays interruptible for the whole handler duration.
Proposed fix:
- Receive eagerly in a dedicated receiver and handle from a queue, shrinking the window to the receive latency.
- Stop trapping
close(). It is only trapped for netlink cookie tracking (NETLINK_NOTIF_SYSCALLS), which can validate the fd lazily instead.
A real fix requires kernel change: https://lore.kernel.org/all/[email protected]/ I don't see any other way to solve this completely in user-space.
Another workaround is of course avoid using native pipeline, use sandlock's pipeline instead.