sandlock
sandlock copied to clipboard
run: write grants under /proc/self only cover the first process
Write-side counterpart of #218. A -w /proc/self/X entry becomes a Landlock rule bound to the first pid's inode, so forked children are denied.
sandlock run -r /usr -r /lib -r /lib64 -r /bin -r /etc -w /proc/self/comm -- \
sh -c "sh -c 'echo x > /proc/self/comm'; true"
sh: 1: cannot create /proc/self/comm: Permission denied
The first process succeeds. Affects forked workers that write oom_score_adj or task/<tid>/comm (the GPU example in docs/cli.md grants -w /proc/self/task).
Proposed fix: serve policy-listed writes on behalf of the caller from procfs::handle_proc_open, opened inside /proc/<tgid> with openat2(RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS). Unlike reads, keep writes policy-gated, and always refuse mem, attr/*, uid_map, gid_map, setgroups, projid_map: the injected fd carries the supervisor's credentials, and procfs checks some of these against the opener.