Repository navigation
Conversation
|
/ok to test 16d0012 |
| /// pipe. Assertions belong in the parent: a panic in the child would | ||
| /// unwind into a copy of the test harness. | ||
| #[allow(unsafe_code)] | ||
| fn fork_capture(child: impl FnOnce() -> Vec<u8>) -> Vec<u8> { |
There was a problem hiding this comment.
Could we run these probes in a fresh executable process using the existing current_exe() and --exact pattern?
Both fork_capture helpers run allocating Rust code after a raw fork, including filter preparation and to_vec(). This violates nix::fork's safety contract when the parent has multiple threads. Calling _exit afterward avoids inherited destructors, but doesn't make the preceding allocations safe.
If the child stalls on an inherited lock, the parent waits indefinitely in the pipe read.
There was a problem hiding this comment.
Done in 0d0372a: fork_capture is gone. Both probe tests now re-exec the test binary (current_exe + --exact + an env-var gate, the same pattern as managed_children), so the rlimit and seccomp changes land in a fresh process and no allocating code runs in a fork child. The parent also requires the child output to show it matched exactly one test, so a wrong --exact name cannot pass vacuously.
16d0012 to
0d0372a
Compare
… clippy Every non-test unsafe block in openshell-sandbox now carries a // SAFETY: comment stating its invariant, and clippy::undocumented_unsafe_blocks is enabled at warn level in the crate roots (lib, the sandbox bin, and the seccomp-perf bin), so the CI clippy lanes with -D warnings fail the build on new undocumented blocks. Test-only blocks are exempt through cfg_attr(test, allow) to keep this change free of test-comment churn; the lint fires 89 times on main and zero times after this change. reset_child_signal_dispositions gains a # Safety section documenting its caller contract (forked pre-exec child only), and the vsock control stream reinterpreted as a UnixStream is documented in place: the family-agnostic operations it relies on, the AF_UNIX members that must never be called on it, and the dial-side twin of the same reinterpretation. Small mechanical edits were required so each comment sits on the line directly above its unsafe block (the lint is line-anchored): nine expressions hoisted into let bindings or nested ifs (five syscall probes in main.rs, two F_SETFL guards in network_broker.rs, two in boundary_server.rs), plus two reorderings (a timeout binding in network_broker.rs, the SAFETY comment placement in seccomp_notify.rs). Every movement preserves the original short-circuits and the errno adjacency the probe helpers rely on, and four new tests pin those properties: two run the self-protection probes against seccomp filters (one lets the FIOSETOWN ioctl through to the kernel, so a probe that reads another syscall's errno fails), and two cover the F_SETFL error arms in connect_exact (an O_PATH descriptor for the transition failure, a deny filter for the restore failure). multiple_unsafe_ops_per_block is deliberately not enabled: it is restriction-group and needs block splits at production sites owned by Closes NVIDIA#5188 Signed-off-by: Emilien Macchi <emacchi@redhat.com>
0d0372a to
32c1957
Compare
|
/ok to test 32c1957 |
Summary
Every non-test
unsafeblock inopenshell-sandboxnow carries a// SAFETY:comment stating its invariant, andclippy::undocumented_unsafe_blocksis enabled at warn level in the crate roots, so the CI clippy lanes fail the build on new undocumented blocks. The lint fires 89 times onmainand zero times after this change.reset_child_signal_dispositionsgains a# Safetysection. The vsock control stream reinterpreted as aUnixStreamis documented in place: which operations it relies on being family-agnostic, whichAF_UNIXmembers must never be called on it, and where the dial side does the same reinterpretation.Related Issue
Closes #5188
Note: the issue is still awaiting
state:accepted, so the PR Issue Acceptance job stays red until a maintainer accepts it.Changes
// SAFETY:comments on non-test unsafe blocks acrossboundary_server.rs(7),main.rs(6),network_broker.rs(3),process.rs(2),sandbox/linux/seccomp.rs(1),linux/seccomp_notify.rs(1)# Safetysection onreset_child_signal_dispositions(forked pre-exec child only)#![warn(clippy::undocumented_unsafe_blocks)]inlib.rs,main.rs, andbin/seccomp-perf.rs, each withcfg_attr(test, allow)for the test-only blocks (after rebasing on fix(sandbox): zero-initialize sigset_t before assume_init #5194's signal-mask tests,main.rsneeds the exemption too: their SAFETY comments sit above theassert_*!line, where the line-anchored lint can't see them)F_SETFLerror arms inconnect_exactThis is not a comment-only change: the movements are mechanical but real, and the tests exist because the existing suites are end-state based and cannot catch a wrong hoist.
Left as follow-ups on purpose:
multiple_unsafe_ops_per_blockstays off: it is restriction-group and needs block splits at 7 production sites, one owned by bug: workload pre_exec hooks compile the seccomp filter and log after fork #5180cfg_attr(test, allow); documenting them would let the allow dropclippy::missing_safety_docnever fires on private bin fns, so the# Safetyhalf of the acceptance criteria has no enforcement after this PRRelease Notes
Testing
cargo clippy -p openshell-sandbox --all-targets(with and without--features perf-harness) with-D warnings, the workspace clippy lanes, andcargo fmt --checkcargo test -p openshell-sandboxgreen, plus the full workspace suite, server tests, and nextest groups locallyThe musl cross-check could not run locally (no musl C cross-compiler on this host); the only change near
cfg(musl)code is a comment move.