fix(broker): end a confined worker's programs when the broker gets SIGQUIT

Merged
KI
22d ago
+40-13

Problem

Ctrl-\ sends SIGQUIT to the broker. The broker did not handle it, so it died without killing its confined worker's process group (RFC 0010). The worker got its death signal, but programs it started kept running, still confined, with the network, their --direct paths, delivered files, and the terminal. The worker leads its own session, so Ctrl-\ reaches only the broker. RFC 0010 lists only SIGKILL as a signal that skips the kill.

Found in an internal review.

Change

  • STOP_SIGNALS in confine.rs adds SIGQUIT to SIGINT, SIGTERM, and SIGHUP. The broker kills the group, then dies by SIGQUIT as it would have.
  • stopping_the_broker_ends_a_confined_worker_and_its_programs sends SIGQUIT too. It turns off the broker's core dumps with prlimit first, so a test run leaves no core file.
  • A signal that only kill sends and the broker does not handle, such as SIGUSR1, is documented with SIGKILL as not covered. Someone who can send it can send SIGKILL too.
  • Docs: RFC 0010 gets a "Changes after release" entry and a sentence under what it does not stop. RFC 0008, the threat model, and the README now name SIGQUIT, and there is a changelog entry.

Verification

  • The test went up first, without the fix (run 43525788319 on f9b421d). It failed on the runner's kernel in check and on Linux 6.12 and 7.3 in kernels, with the worker or its program outlived a stopped broker on the SIGQUIT pass. SIGTERM, SIGINT, and SIGHUP passed before it, and prlimit succeeded. The fix is the second commit, eb2feda.
  • Locally on macOS (no Linux here): cargo fmt --all --check; cargo +1.100.0 clippy --locked --all-targets -- -D warnings is clean for x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, and macOS; cargo +1.85.0 check --locked --all-targets --target x86_64-unknown-linux-gnu passed; cargo test --locked 121 passed, 0 failed.

Not verified locally: any Linux run. That is this PR's CI on the fix commit.

Documentation and release

RFC 0008, RFC 0010, the threat model, the README, and the changelog. No version change.