Expand description
Seccomp user notification (SECCOMP_RET_USER_NOTIF) support.
Seccomp user notification allows a supervisor process to intercept syscalls from a sandboxed child and make decisions on its behalf. This enables filesystem virtualization without user namespaces.
§Architecture
- Child installs a seccomp filter with
SECCOMP_FILTER_FLAG_NEW_LISTENER - This returns a “listener fd” which is passed to the parent via
SCM_RIGHTS - Parent polls the listener fd; when readable, calls
SECCOMP_IOCTL_NOTIF_RECV - Parent inspects the syscall and either:
- Returns
SECCOMP_USER_NOTIF_FLAG_CONTINUEto let it proceed - Returns an error code to deny it
- Uses
SECCOMP_IOCTL_NOTIF_ADDFDto inject a file descriptor
- Returns
§TOCTOU Protection
Between receiving a notification and responding, the child’s memory may change.
Always call SECCOMP_IOCTL_NOTIF_ID_VALID after reading child memory to verify
the notification is still valid.
Structs§
- Seccomp
Data - Seccomp notification data (mirrors kernel
struct seccomp_data). - Seccomp
Notif - Seccomp notification received from the child (mirrors kernel
struct seccomp_notif). - Seccomp
Notif Addfd - Inject a file descriptor into the notifying process
(mirrors kernel
struct seccomp_notif_addfd). - Seccomp
Notif Resp - Response to a seccomp notification (mirrors kernel
struct seccomp_notif_resp).
Constants§
- SECCOMP_
ADDFD_ FLAG_ SEND - Atomically inject fd and respond to the notification.
- SECCOMP_
ADDFD_ FLAG_ SETFD - Replace an existing fd in the target process.
- SECCOMP_
FILTER_ FLAG_ NEW_ LISTENER - SECCOMP_
IOCTL_ NOTIF_ ADDFD - ioctl to inject a file descriptor into the notifying process.
- SECCOMP_
IOCTL_ NOTIF_ ID_ VALID - ioctl to check if a notification ID is still valid (TOCTOU protection).
- SECCOMP_
IOCTL_ NOTIF_ RECV - ioctl to receive a notification from the seccomp listener fd.
- SECCOMP_
IOCTL_ NOTIF_ SEND - ioctl to send a response to a seccomp notification.
- SECCOMP_
USER_ NOTIF_ FLAG_ CONTINUE - Let the syscall proceed as-is (supervisor approves).
Functions§
- notif_
addfd - Inject a file descriptor into the notifying process.
- notif_
id_ valid - Check if a notification ID is still valid.
- notif_
recv - Receive a notification from the seccomp listener fd.
- notif_
send - Send a response to a seccomp notification.
- seccomp_
set_ ⚠mode_ filter_ listener - Install a seccomp filter with
SECCOMP_FILTER_FLAG_NEW_LISTENER.