COW copy-up of a FIFO hangs the supervisor indefinitely
execute_copy opens the lower file with O_RDONLY and no file-type check (cow/seccomp.rs:508-514). Opening a FIFO that way blocks until a writer appears, so a child that touches a FIFO under the workdir wedges the supervisor thread performing the copy-up. The supervisor is not confined by the child's policy and nothing times the open out, so the hang is indefinite.
The project already treats this exact hazard as known in the Landlock path-rule code — test_path_rule_on_fifo_does_not_block states it plainly: "Opening a FIFO with O_RDONLY blocks until a writer appears. add_path_rule must reference the path with O_PATH so a read rule on a FIFO does not hang child setup." The COW copy-up path has no equivalent guard.
Reproducer (a unit probe against the branch API, so the wedge is visible without a cage):
let fifo = workdir.path().join("pipe");
let c = std::ffi::CString::new(fifo.to_str().unwrap()).unwrap();
assert_eq!(unsafe { libc::mkfifo(c.as_ptr(), 0o644) }, 0);
let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || {
let mut b = SeccompCowBranch::create(&wd, Some(&sd), 0).unwrap();
let _ = tx.send(format!("{:?}", b.ensure_cow_copy("pipe").map(|_| "Ok")));
});
match rx.recv_timeout(std::time::Duration::from_secs(5)) {
Ok(v) => println!("returned: {v}"),
Err(_) => println!("*** HUNG (no return in 5s) ***"),
}
Observed: *** HUNG (no return in 5s) ***. The thread never returns.
From inside the sandbox this is one line of unprivileged code — write to a FIFO that exists in the workdir, or create one first if mknod/mkfifo is reachable under the policy. Severity is availability only: the copy is confined to the workdir root (openat2_in_root), so this is a wedge, not an escape.
Where the fix belongs is execute_copy, before the source open — the destination side is fine. Either stat the source and require S_IFREG/S_IFLNK, or open O_RDONLY | O_NONBLOCK and reject anything that is not a regular file after the fact. The EACCES/ENOENT arm two lines below already establishes the pattern for "give the child an empty COW file and move on", which looks like the right disposition for a non-regular source as well — a FIFO's contents are not meaningful to copy up.
Found while writing COW merge tests for #148; unrelated to that PR's subject, hence a separate report. Reproduced on main at 44b1c65.