Fix /tmp cleanup and verify absent parent ENOENT#212
Conversation
860a5a9 to
33fc1df
Compare
|
Looking at the callers, containment is invoked only after sysroot_path_exists(), after The issue’s /etc/sysusers.d/basic.conf example also does not take this path today: when the Please provide a concrete reproducer that reaches this fallback, or clarify that the change only |
Actions Completed
|
jserv
left a comment
There was a problem hiding this comment.
The new walk-up in sysroot_path_is_contained fires only under the single-window TOCTOU that the module comment (proc-state.c:469) already declares out of scope, so the actionable issue is the fail-open regression noted inline, not the race itself. Two lower-priority items without their own anchor: str_copy_trunc in realpath_existing_parent (:448) silently truncates an over-long path and could authorize a different, shorter contained path — security code should fail closed with ENAMETOOLONG; and the test's rmdir(race_dir) cleanup can leave residue (ENOTEMPTY) if a race iteration created file.txt inside.
| mounted_sysroot_root); | ||
| snprintf(race_file, sizeof(race_file), "/tmp/race_dir/file.txt"); | ||
|
|
||
| pid_t pid = fork(); |
There was a problem hiding this comment.
fork()'s return isn't checked. On -1 the child branch is skipped and kill(pid, SIGKILL) becomes kill(-1, SIGKILL) — SIGKILL to every process the user can signal, then waitpid(-1, ...) reaps an arbitrary child. Add if (pid < 0) FAIL(...) before the split.
jserv
left a comment
There was a problem hiding this comment.
Enforce rules specified in https://cbea.ms/git-commit/ .
c43e5ac to
3066dd4
Compare
A preceding test left ${sysroot}/tmp as a symlink to host-out, causing
downstream creation tests to hit the symlink-rejecting directory
creation path and fail with ELOOP. We now restore the /tmp directory
at the end of the test.
Since containment checks are only run on paths verified to exist,
checks on absent intermediate directories only occur via a TOCTOU race.
The recursive parent resolution walk-up in sysroot_path_is_contained
has been reverted to a secure, fail-closed behavior to prevent any
fail-open vulnerabilities.
A deterministic test is added to verify that opening a path with a
non-existent parent returns ENOENT (and not ELOOP). The TOCTOU racer
is kept as a non-fatal stress check, asserting that no artifacts are
written outside of the sysroot mount.
Fixes sysprog21#187
|
Updated commit message |
1. Reverted to Fail-Closed containment behavior in proc-state.c
2. Robust Test Process Fork Handling in test-sysroot-create-paths.c
3. Deterministic
|
Fix /tmp cleanup and verify absent parent ENOENT
A preceding test left ${sysroot}/tmp as a symlink to host-out, causing
downstream creation tests to hit the symlink-rejecting directory
creation path and fail with ELOOP. We now restore the /tmp directory
at the end of the test.
Since containment checks are only run on paths verified to exist,
checks on absent intermediate directories only occur via a TOCTOU race.
The recursive parent resolution walk-up in sysroot_path_is_contained
has been reverted to a secure, fail-closed behavior to prevent any
fail-open vulnerabilities.
A deterministic test is added to verify that opening a path with a
non-existent parent returns ENOENT (and not ELOOP). The TOCTOU racer
is kept as a non-fatal stress check, asserting that no artifacts are
written outside of the sysroot mount.
Fix #187
Summary by cubic
Return ENOENT/ENOTDIR for paths with missing or non-directory components instead of ELOOP, and harden tests to prevent false ELOOPs. Fixes #187.
/tmpinside the sysroot after tests to remove a leftover symlink that caused spurious ELOOPs.Written for commit 3066dd4. Summary will update on new commits.