Expand description
Handlers for syscalls answered through seccomp user notification.
Each handler reads its path arguments out of the tracee, translates them into the guest filesystem view, performs the real syscall in the supervisor, and answers with a value, an error, or an injected descriptor. The kernel never sees an untranslated guest path for the syscalls routed here.
The syscall is made on what the walk resolved, not on a host path string
the kernel would walk again: the *at form relative to the pinned parent
directory with O_NOFOLLOW/AT_SYMLINK_NOFOLLOW, since the walk already
followed a final symlink when asked to. A symlink found at that point was
swapped in by the guest after the walk; the handler then walks again, a
few times, so the link is resolved inside the guest namespace, and gives
up with ELOOP. Syscalls without a dirfd form act on the objectβs
/proc/self/fd/<n>, which the kernel resolves to the open inode.
Every notification is answered exactly once. After tracee memory has been read and before anything irreversible happens, the notification id is re-validated; a stale id (the tracee died or was interrupted by a signal) is dropped silently.
StructsΒ§
- Req π
- One notification plus the shared state needed to serve it.
EnumsΒ§
- Outcome π
- How a handler wants the notification answered.
ConstantsΒ§
- DROPPED π
- Sentinel errno meaning βthe notification is stale, do not answerβ.
- IN_
DONT_ πFOLLOW IN_DONT_FOLLOWforinotify_add_watch(2).- RETRIES π
- Walks of one call after a swapped-in symlink was found where the walk
had followed none, before the call fails with
ELOOP. - SYS_
FCHMODA πT2_ HOST fchmodat2(2)is 452 on every architecture; the libc crate lacks it for aarch64.- WRITE_
INTENT π open(2)flags that imply the caller intends to modify the file.- XATTR_
MAX π - Largest extended attribute value or list we shuttle through.
FunctionsΒ§
- cstr π
- Builds a C string from path bytes.
- dispatch π
- Routes a syscall number to its handler.
- do_
access π access/faccessat/faccessat2.- do_
chmod π chmod/fchmodat/fchmodat2, on the objectβs/proc/self/fdlink.- do_
chown π chown/lchown/fchownat.- do_
fchown π fchownunder-0: through the descriptorβs/proclink; a refusal is forgiven.- do_
getcwd π getcwd: the traceeβs cwd as a guest path, NUL-terminated.- do_
getgroups π getgroups(size, list)under-0: the recorded list, or the kernelβs when none was set.- do_
getxattr π getxattr/lgetxattr.- do_
identity π - The identity syscalls under
-0, over the processβs virtualcrate::procs::Ids. - do_
inotify_ πadd_ watch inotify_add_watch.- do_link π
link/linkat. An empty old path withAT_EMPTY_PATHlinks the traceeβs descriptor via its/procentry. The walk followed the old side when asked to, so the kernel is never asked to follow it again.- do_
listxattr π listxattr/llistxattr.- do_
mkdir π mkdir/mkdirat.- do_
mknod π mknod/mknodat.- do_open π
open/creat/openat: open in the supervisor and inject the descriptor.- do_
openat2 π openat2: likeopenatwith astruct open_how.- do_
prctl π prctl(PR_SET_DUMPABLE)andPR_GET_DUMPABLE.- do_
readlink π readlink/readlinkat: raw target, except/procmagic links are detranslated.- do_
removexattr π removexattr/lremovexattr.- do_
rename π rename/renameat/renameat2. A mount point of the view is busy, as a mount point is.- do_
setgroups π setgroups(size, list)under-0: recorded forgetgroups, never applied.- do_
setxattr π setxattr/lsetxattr.- do_stat π
stat/lstat/newfstatat: fill the hostβsstruct statin the tracee (144 bytes on x86_64, 128 on aarch64), converted for i386 callers.- do_
statfs π statfs: fill a 120-bytestruct statfsin the tracee.- do_
statx π statx: fill a 256-bytestruct statxin the tracee.- do_
symlink π symlink/symlinkat: the target is stored verbatim, only the link path is translated.- do_
truncate π truncate, on the objectβs/proc/self/fdlink.- do_
uname π uname: the hostβs answer withreleaseand/ornodenamereplaced.- do_
unlink π unlink/unlinkat/rmdir. A mount point of the view is busy, as a mount point is.- do_
utime π utime:struct utimbuf(two seconds fields) to timespecs.- do_
utimensat π utimensat. A NULL path targets the descriptor itself and is passed through.- do_
utimes π utimes/futimesat:struct timeval[2]to timespecs.- fake_
ids_ πfor_ status - Under
-0, the virtual identity to show in a/proc/<pid>/statusbeing opened. - fake_
owner π - Under
-0, files owned by the supervisorβs own ids belong to root. - fake_
proc_ πcmdline - Serves
/proc/<pid>/cmdlineas the process was started, without the loader the exec was retargeted at. - fake_
proc_ πfile - Serves an opened
/proc/<pid>/statusorcmdlinefrom a rewritten copy. - fake_
proc_ πstatus - Serves
/proc/<pid>/statuswith our own pid hidden fromTracerPidand, under-0, root in theUid/Gidlines. - follow π
- Deref policy derived from
AT_SYMLINK_NOFOLLOW. - forgive_
as_ πroot - Under
-0, an ownership or device-node refusal reads as success, like PRootβs fake_id0. - handle
- Serves one notification. Always answers exactly once, unless the notification turned out to be stale.
- host_
utimensat π - Runs
utimensat(2)on a resolved path with an optional timespec pair. - is_fifo π
- Whether the resolved object is a FIFO; opening one may block the supervisor.
- lexical_
clean π - Lexically cleans an absolute path (no symlink resolution).
- nofollow_
flag π - The
AT_SYMLINK_NOFOLLOWbit to pass for an act on a resolved path. - nofollow_
open_ πflag O_NOFOLLOWwhen the host open must not follow a final symlink.- proc_
magic_ πlink - Classifies a guest path as a
/proc/<pid>/...magic link. - read_
all π - Reads all of an open descriptor without taking ownership of it.
- readlink_
by_ πpath - The target of the link
pathnames, ordirfdwas opened on for an empty path, read by its path. - readonly_
memfd π - A read-only descriptor on a memfd holding
content. - retrying π
- Runs a handler again while it reports a swapped-in symlink (
RETRY). - rewrite_
proc_ πself - Replaces a leading
/proc/selfor/proc/thread-selfwith the traceeβs pid. - targets_
fd π - Whether a path argument is empty with
AT_EMPTY_PATH, i.e. targets the fd itself. - timespecs_
from_ πtracee - Reads a
struct timespec[2]from the tracee, widening 32-bit fields for i386utimensat. - timevals_
to_ πtimespecs - Reads a
struct timeval[2]from the tracee and converts it to 64-bit timespecs. - xattr_
target π - The path an extended-attribute syscall acts on.