mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
b195b1de88
* chmod: fix TOCTOU race in recursive traversal Use fchmodat2 (Linux 6.6+) with AT_SYMLINK_NOFOLLOW to prevent an attacker from replacing a directory entry with a symlink between the stat and chmod calls. Falls back to fchmodat on older kernels. - Restrict fchmodat2 (syscall 452) to asm-generic architectures only (x86_64, x86, arm, aarch64, riscv) - Add SAFETY comment on unsafe syscall block per project convention - Add O_PATH + /proc/self/fd fallback for musl on kernel < 6.6 - Cache ENOSYS result with AtomicBool to skip fchmodat2 on old kernels - Remove unnecessary nix::Mode round-trip on the fchmodat2 path - safe_chmod_file() takes explicit SymlinkBehavior parameter - Always pass NoFollow for regular entries during recursion - Document residual TOCTOU in symlink branch as intentional for -L - Add test verifying NoFollow chmod doesn't modify symlink target - Update check-safe-traversal.sh to recognize fchmodat2