Repository navigation
Conversation
|
/ok to test bdeb980 |
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. api-behavior — No explicit risk acceptance foundPID-zero prlimit64 and sched_set* calls now enter interruptible seccomp mediation instead of executing natively.
Review details
Advisory review; publication gates are unchanged. |
|
Label |
|
/ok to test bdeb980 |
bdeb980 to
8e8a4f6
Compare
The rt_sigqueueinfo emulation passed the workload's siginfo to pidfd_send_signal unchanged, but the kernel rejects a siginfo whose si_signo differs from the signal argument with EINVAL, while native rt_sigqueueinfo overwrites si_signo with the requested signal. A workload that leaves si_signo unset therefore failed only under OpenShell. Mirror the kernel by overwriting si_signo after the existing si_code check, and cover it with a forked-child test that queues a signal with a deliberately mismatched si_signo and asserts the delivered signo and value. Signed-off-by: Emilien Macchi <emacchi@redhat.com>
8e8a4f6 to
97fbbf6
Compare
|
/ok to test 97fbbf6 |
FrostGod
left a comment
There was a problem hiding this comment.
Thanks for the thorough fix and tests. A few general notes; inline comments follow.
- Logging: every
Errfrom the new mediation is logged as"sandbox network notification denied"(network_broker.rs:328). That includes plain usage errors likeESRCH/EINVAL, and none of these are network events. Cross-groupEPERMdenials are policy decisions and would warrant an OCSF event perAGENTS.md. The signal path already works this way, so a follow-up issue is fine. - PID reuse (
process_sched.rs:31-39): accepting this risk seems reasonable and is well documented. Please call it out in the PR description so reviewers sign off explicitly. - Merge order: agree on ordering with #5161 before either lands, since both change the signal mediation paths.
A self-directed kill or rt_sigqueueinfo was emulated by sending through the retained pidfd while the caller was still blocked in its seccomp notification, so the delivered signal interrupted the very syscall being emulated: without SA_RESTART the call returned EINTR, and with SA_RESTART it restarted and was notified again. Continue the notification instead when the target group is the notifying thread's own group. The kernel then executes the syscall after the notification wait, so its result and siginfo are the workload's own: an errno such as EAGAIN under an exhausted RLIMIT_SIGPENDING stays visible, si_pid and si_uid name the workload rather than the broker, and a handler runs exactly when it would without mediation. The frozen-workload SIGCONT gate and the queued-signal si_code check stay ahead of the continuation; other targets keep the retained-pidfd delivery. Continuing an inspected numeric target has the same PID-reuse window as the tkill precedent. Cover it with forked-child tests: a self-directed kill, a kill that names a sibling thread's TID, and a self-directed queued signal complete natively with the handler observed, and a queued signal under a zero RLIMIT_SIGPENDING reports the native EAGAIN instead of success. Signed-off-by: Emilien Macchi <emacchi@redhat.com>
…ss group The child hardening filter denied sched_setaffinity, sched_setattr, sched_setparam, sched_setscheduler, and prlimit64 for any nonzero PID argument and setpriority outright, so thread pinning (pthread_setaffinity_np and GOMP_CPU_AFFINITY pass a kernel TID), taskset -p, psutil cpu_affinity(pid), prlimit(getpid()), and nice all failed with EPERM inside sandboxes while working in a plain container. A cBPF filter cannot compare an argument against the caller's own thread group, and SECCOMP_RET_ERRNO outranks the user-notification action, so the denies cannot be narrowed in place. Move the six syscalls to broker mediation instead: the workload listener now notifies them when they name a target, and the broker continues the call when the target is in the caller's own thread group (own TGID or a sibling TID resolved through /proc), preserves ESRCH for vanished targets, and fails closed with EPERM for everything else, including a caller it cannot identify. setpriority is limited to PRIO_PROCESS, since PRIO_USER names every process of the shared workload UID and PRIO_PGRP names a group an untrusted child can rejoin. The static filter keeps an equal-deny on the trusted sandbox leader as defense in depth, on argument 1 for setpriority whose PID is the second argument. A call with pid 0 names only the caller, which cBPF can check, so the listener filter allows it without a notification (for setpriority only under PRIO_PROCESS). Those calls keep their native, non-interruptible behavior, and the prlimit64(0, ...) the pre-exec hardening hook issues never waits on the broker. A child that does not inherit the workload listener, the socket probe, takes prepare_without_broker, which keeps the previous static rules. Shared /proc thread-group resolution moves to linux/proc_status and the new mediation lives in linux/process_sched. Cover the filter and broker with allow, deny, ESRCH, and native pid 0 path tests, and add an e2e that runs inside a real sandbox: thread affinity, self and sibling-TID signals, nice, a raw prlimit64, a queued signal with a mismatched si_signo, and denied calls against a same-UID child and the sandbox parent. Signed-off-by: Emilien Macchi <emacchi@redhat.com>
97fbbf6 to
d4fe133
Compare
|
Pushed d4fe133 with everything below folded into the three commits. Inline replies are on each thread.
|
Summary
Three compatibility fixes for the mediated signal and scheduling syscalls, so common tooling (pthread affinity,
taskset -p,nice,prlimit(getpid()), self-signals,sigqueue) behaves inside a sandbox as it does in a plain container.Related Issue
Closes #5185
Changes
rt_sigqueueinfomediation now setssi_signoto the requested signal beforepidfd_send_signal. The kernel rejects a mismatched siginfo with EINVAL there, while nativert_sigqueueinfooverwrites the field.kill/rt_sigqueueinfonotifications (the caller's PID or a sibling TID) are continued instead of emulated through a pidfd. The kernel executes the syscall after the notification wait, so errno (for example EAGAIN under an exhausted RLIMIT_SIGPENDING), siginfo identity, and handler timing are the workload's own, and the delivered signal can no longer interrupt the call being emulated (the EINTR and restart-and-renotify loops from the issue).sched_setaffinity,sched_setattr,sched_setparam,sched_setscheduler,prlimit64, andsetprioritymove from static child-filter denies to broker mediation, following the existing tkill resolve-then-continue pattern: the caller's own TGID and sibling TIDs in its thread group are allowed; every other target stays EPERM.setpriorityaccepts only PRIO_PROCESS (PRIO_PGRP and PRIO_USER stay denied because they can reach the shared workload UID or a rejoined process group), and invalid arguments keep their native EINVAL/ESRCH. A static equal-deny on the trusted sandbox leader remains as defense in depth.MEDIATED_PROCESS_SCHED_SYSCALLS; the notified set, the cBPF pid 0 path, broker dispatch, static deny, and argument decode all derive from it.child_seccomp::prepare_without_broker, which keeps the previous static rules: pid 0 only,setprioritydenied.sandbox_compat_signals_schedruns inside a real sandbox via python3: thread affinity, self and sibling-TID signals,os.nice, rawprlimit64, a queued signal with a mismatchedsi_signo, and denial probes against a same-UID child and the sandbox parent. Docker and Kubernetes lanes pick it up by default; it is added to the podman CI allowlist.Accepted risk: PID reuse on a continued target
Linux has no pidfd form of
sched_*,prlimit64, orsetpriority, so the broker resolves a named target through procfs and continues the syscall with the numeric TID. A PID reused between that check and kernel execution could redirect the call to another same-UID task. This is the same class as the existingtkillresolve-then-continue, the window is one broker round trip, and the trusted sandbox leader stays covered by the static equal-deny. Documented in theprocess_schedmodule doc. Reviewers, please sign off on this explicitly.Merge coordination: #5161 also changes
child_seccomp::prepareandmediate_process_signal; whichever lands second needs a rebase.Release Notes
Sandboxed workloads can now set their own CPU affinity, nice value, and resource limits, signal themselves, and queue signals, the same as in a plain container. Calls targeting processes outside the workload's own thread group are still denied.
Testing
cargo test -p openshell-sandbox(345 lib tests, including allow/deny, native-errno, EAGAIN, sibling-TID, and pid 0 native-path tests)cargo clippy -p openshell-sandbox --all-targets --features perf-harness -- -D warnings;cargo fmt --all --checkcargo zigbuild check --target x86_64-unknown-linux-musl -p openshell-sandbox(the previous head did not build on musl)e2e:podmanlane withsandbox_compat_signals_schedmise run rust:lint/pre-commitfail on this workstation before reaching any code check (rpm-shipped/etc/uv/uv.tomlthe pinned uv cannot parse); the cargo-level equivalents above all pass.Checklist