There are two syscalls fchmodat and fchmodat2 but only one glibc wrapper: int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags); The PRE wrappers in coregrind/m_syswrap/syswrap-linux.c simply do: if ( !ML_(fd_allowed)(SARG1, "fchmodat", tid, False) ) SET_STATUS_Failure( VKI_EBADF ); if ( !ML_(fd_allowed)(SARG1, "fchmodat2", tid, False) ) SET_STATUS_Failure( VKI_EBADF ); This doesn't handle AT_FDCWD or absolute paths (then fd should be ignored). fchmodat01.c:47: TFAIL: fchmodat(-100, fchmodatdir/fchmodatfile, 0600, 0) failed: EBADF (9) fchmodat02.c:55: TFAIL: fchmodat() with invalid flag expected EINVAL: EBADF (9) Note that the fchmodat2 testcases don't seem to check for AT_FDCWD or absolute paths. This also seems to cause a lot of arm64 LTP failures
Created attachment 183804 [details] proposed patch
Created attachment 183809 [details] proposed patch
(In reply to mcermak from comment #2) > Created attachment 183809 [details] > proposed patch Looks good. Pushed as: commit 90d4ed67ff52b859bf1f2d8cbea8816ca705d6f6 Author: Martin Cermak <mcermak@redhat.com> Date: Tue Aug 5 17:36:29 2025 +0200 Make fchmodat and fchmodat2 syscall wrappers accept AT_FDCWD The fchmodat and fchmodat2 syscall wrappers should accept special value AT_FDCWD as a valid file descriptor. https://bugs.kde.org/show_bug.cgi?id=507873