Skip to content

jail/seccomp: complete the pre-main syscall allowlists - #49

Merged
openwrt-bot merged 1 commit into
openwrt:mainfrom
dangowrt:procd-seccomp-premain
Sep 25, 2026
Merged

openwrt-bot merged 1 commit into
openwrt:mainfrom
dangowrt:procd-seccomp-premain

Conversation

@dangowrt

Copy link
Copy Markdown
Member

The ptrace seccomp injection added in f15d0c4 arms a phase-1 filter at the post-execve stop, before ld.so runs, made of the profile plus a fixed allowlist of the syscalls a libc issues before the workload reaches its entry point and main. That allowlist only names the 64-bit syscalls. A 32-bit libc sets its thread pointer with set_tls on ARM and set_thread_area on MIPS and i386, and maps and inspects its objects with mmap2, fstat64, fstatat64, statx, fcntl64 and the 64-suffixed statfs calls; glibc and bionic also read the stack limit with ugetrlimit or getrlimit there. The first syscall of ld.so therefore hits the profile's default action, and a SCMP_ACT_KILL_PROCESS profile kills the jailed process before the entry breakpoint. This is how umdns dies on every 32-bit target since the 2026-09-13 procd bump, see openwrt/openwrt#25392. A static glibc binary further resolves its origin in _dl_non_dynamic_init() with readlinkat on /proc/self/exe before main, which the static pre-main list omitted as well.

The allowlists now carry the 32-bit names and readlinkat for the static pre-main phase. The grants and the deltas that revoke them at the entry and main boundaries are kept in step, so the filter in force once main runs is still exactly the profile. find_syscall() skips a name the target does not have, so one list serves every architecture.

Evidence: musl 1.2.6 __dls2b -> __init_tp() -> __set_thread_area() (raw 0xf0005 on ARM, SYS_set_thread_area elsewhere) and the 32-bit remaps in src/internal/syscall.h; a qemu-mips syscall trace of a musl binary from the mips_24kc staging root; a host strace of a -m32 glibc binary (set_thread_area, mmap2, statx, ugetrlimit before main); glibc 2.43 sysdeps/unix/sysv/linux/arm/tls.h (set_tls), sysdeps/mips/nptl/tls.h and sysdeps/i386/nptl/tls.h (set_thread_area); bionic libc/SYSCALLS.TXT (__ARM_NR_set_tls, set_thread_area, ugetrlimit, lp32 statfs64/fstatfs64); a static glibc test program with a getpid marker in main showing readlinkat before it on x86_64 and i386. The change is compile-checked for x86_64; a runtime test on a 32-bit target is still outstanding.

The loader and pre-main allowlists name the syscalls a 64-bit libc
issues before the workload reaches its entry point. A 32-bit libc sets
its thread pointer with set_tls on ARM and set_thread_area on MIPS and
i386, and maps and inspects its objects with mmap2, fstat64, fstatat64,
statx, fcntl64 and the 64-suffixed statfs calls; glibc and bionic also
read the stack limit with ugetrlimit or getrlimit there. None of these
are in the lists, so the first syscall of ld.so already hits the
profile's default action and a SCMP_ACT_KILL_PROCESS profile kills the
jailed process before the entry breakpoint, which is how umdns dies on
every 32-bit target. A static glibc binary further resolves its origin
in _dl_non_dynamic_init(), reading the /proc/self/exe link with
readlinkat before main, which the static pre-main list omits as well.

Add the names to the lists so the grants and the deltas that revoke
them stay in step; find_syscall() skips a name the target does not
have.

Fixes: f15d0c4 ("jail: apply OCI seccomp filters via ptrace syscall injection")
Fixes: openwrt/openwrt#25392
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
@willmo

willmo commented Sep 25, 2026 •

Copy link
Copy Markdown

Supersedes #47 so I'll close that. I should be able to test at least on kirkwood (32-bit ARM) later today.

@openwrt-bot
openwrt-bot merged commit a6f9ffd into openwrt:main Sep 25, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants