| Summary: | fchmodat fchmodat2 should handle AT_FDCWD and absolute paths | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | Mark Wielaard <mark> |
| Component: | general | Assignee: | mcermak |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | mcermak |
| Priority: | NOR | ||
| Version First Reported In: | 3.25 GIT | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Bug Depends on: | |||
| Bug Blocks: | 506971 | ||
| Attachments: |
proposed patch
proposed patch |
||
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 |
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