Skip to content

Commit 6ce14f1

Browse files
committed
test: add regression guard for recursive chmod dirfd-relative traversal
Add a check in check-safe-traversal.sh to ensure recursive chmod operations use dirfd-relative openat calls instead of AT_FDCWD with multi-component paths, preventing potential race conditions. Ignore the corresponding Rust test as it is now covered by this shell script guard.
1 parent 4ce6cd1 commit 6ce14f1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tests/by-util/test_chmod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ fn test_chmod_non_utf8_paths() {
12831283

12841284
#[cfg(all(target_os = "linux", feature = "chmod"))]
12851285
#[test]
1286+
#[ignore = "covered by util/check-safe-traversal.sh"]
12861287
fn test_chmod_recursive_uses_dirfd_for_subdirs() {
12871288
use std::process::Command;
12881289
use uutests::get_tests_binary;

util/check-safe-traversal.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ fi
173173
if echo "$AVAILABLE_UTILS" | grep -q "chmod"; then
174174
cp -r test_dir test_chmod
175175
check_utility "chmod" "openat,fchmodat,newfstatat,chmod" "openat fchmodat" "-R 755 test_chmod" "recursive_chmod"
176+
177+
# Additional regression guard: ensure recursion uses dirfd-relative openat, not AT_FDCWD with a multi-component path
178+
if grep -q 'openat(AT_FDCWD, "test_chmod/' strace_chmod_recursive_chmod.log; then
179+
fail_immediately "chmod recursed using AT_FDCWD with a multi-component path; expected dirfd-relative openat"
180+
fi
176181
fi
177182

178183
# Test chown - should use openat, fchownat, newfstatat

0 commit comments

Comments
 (0)