Bug 507868 - futimesat doesn't handle AT_FDCWD
Summary: futimesat doesn't handle AT_FDCWD
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: 3.25 GIT
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: mcermak
URL:
Keywords:
Depends on:
Blocks: 506971
  Show dependency treegraph
 
Reported: 2025-08-04 21:48 UTC by Mark Wielaard
Modified: 2025-08-06 17:24 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
proposed patch (1.52 KB, patch)
2025-08-05 12:58 UTC, mcermak
Details
proposed patch (2.04 KB, patch)
2025-08-05 13:33 UTC, mcermak
Details
proposed patch (2.33 KB, patch)
2025-08-05 14:56 UTC, mcermak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2025-08-04 21:48:21 UTC
Like other "at" syscalls fd can have the special value AT_FDCWD which is an "invalid file descriptor".

The LTP futimesat01 testcase shows:

==695142== Warning: invalid file descriptor -100 in syscall futimesat()
futimesat01    5  TFAIL  :  futimesat01.c:85: futimesat() failed: TEST_ERRNO=EBADF(9): Bad file descriptor

There is no LTP testcase for it, but if pathname is absolute, then fd is ignored.
Comment 1 mcermak 2025-08-05 12:58:08 UTC
Created attachment 183803 [details]
proposed patch
Comment 2 mcermak 2025-08-05 13:33:08 UTC
Created attachment 183805 [details]
proposed patch
Comment 3 mcermak 2025-08-05 14:56:04 UTC
Created attachment 183808 [details]
proposed patch
Comment 4 Mark Wielaard 2025-08-06 17:24:08 UTC
(In reply to mcermak from comment #3)
> Created attachment 183808 [details]
> proposed patch

Looks good. Pushed as:

commit bdbce5686e4204d678814fa861d153c5bc5252f8
Author: Martin Cermak <mcermak@redhat.com>
Date:   Tue Aug 5 16:54:54 2025 +0200

    The futimesat syscall wrapper doesn't handle AT_FDCWD
    
    Update futimesat syscall wrapper so that it doesn't consider the
    special value AT_FDCWD (-100) an invalid file descriptor.
    
    https://bugs.kde.org/show_bug.cgi?id=507868