[all-commits] [llvm/llvm-project] c53000: [libc] Reject unsupported flags in fchmodat with E...

Aman Maurya via All-commits all-commits at lists.llvm.org
Wed Sep 16 01:47:40 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c53000a7282bedb125ffaab8cb072df85596d095
      https://github.com/llvm/llvm-project/commit/c53000a7282bedb125ffaab8cb072df85596d095
  Author: Aman Maurya <amanmaurya9209 at gmail.com>
  Date:   2026-09-16 (Wed, 16 Sep 2026)

  Changed paths:
    M libc/src/__support/OSUtil/linux/syscall_wrappers/fchmodat.h
    M libc/src/sys/stat/linux/CMakeLists.txt
    M libc/src/sys/stat/linux/fchmodat.cpp
    M libc/test/src/sys/stat/CMakeLists.txt
    M libc/test/src/sys/stat/fchmodat_test.cpp

  Log Message:
  -----------
  [libc] Reject unsupported flags in fchmodat with ENOTSUP (#223165)

### Summary
The Linux kernel's `SYS_fchmodat` system call only takes 3 arguments
(`dirfd`, `pathname`, `mode`), but our syscall wrapper was passing a 4th
`flags` argument that the kernel simply dropped.

This PR cleans up the wrapper to pass the 3 arguments expected by the
kernel, and adds a check to `fchmodat` to return `-1` with `ENOTSUP`
whenever non-zero flags (like `AT_SYMLINK_NOFOLLOW`) are passed.

Fixes #223072

### Changes
- Cleaned up `linux_syscalls::fchmodat` to pass only 3 arguments to
`SYS_fchmodat`.
- Added a check in `fchmodat` entrypoint to set `libc_errno = ENOTSUP`
and return `-1` if `flags != 0`.
- Added `libc.hdr.errno_macros` to the CMake dependencies for `fchmodat`
and its unit test.
- Added tests in `fchmodat_test.cpp` to verify that passing non-zero
flags fails with `ENOTSUP`.

### Testing
- Ran `clang-format` on touched files.
- Built and ran hermetic tests: `libc.test.src.sys.stat.fchmodat_test`
(all 3 tests pass: `ChangeAndOpen`, `NonExistentFile`,
`UnsupportedFlags`).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list