Bug 508154

Summary: Multiple ltpchecks failures caused by PRE(sys_fchownat) not handling VKI_AT_FDCWD
Product: [Developer tools] valgrind Reporter: mcermak
Component: generalAssignee: mcermak
Status: RESOLVED FIXED    
Severity: normal CC: mark
Priority: NOR    
Version First Reported In: 3.25 GIT   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 506971    
Attachments: proposed patch
proposed patch

Description mcermak 2025-08-12 10:22:20 UTC
I see multiple `make ltpchecks` failures caused by PRE(sys_fchownat) not handling VKI_AT_FDCWD properly.  This specifically impacts aarch64 test results these days.
Comment 1 mcermak 2025-08-12 10:26:12 UTC
Created attachment 183985 [details]
proposed patch
Comment 2 Mark Wielaard 2025-08-12 17:51:26 UTC
(In reply to mcermak from comment #1)
> Created attachment 183985 [details]
> proposed patch

> -   if ( !ML_(fd_allowed)(SARG1, "fchownat", tid, False) )
> +   if ( (arg_1 != VKI_AT_FDCWD) && !ML_(fd_allowed)(arg_1, "fchownat", tid, False) )

This doesn't seem to handle the absolute path case:

       If pathname is absolute, then dirfd is ignored.

Maybe something (untested) like:
const HChar* path = (const HChar*)ARG2;
if (ML_(safe_to_deref)(path, 1) && path[0] != '/')
...
Comment 3 mcermak 2025-08-13 07:06:12 UTC
Created attachment 184028 [details]
proposed patch

Thank you for the review.  Updated patch attached.  Please check.
Comment 4 Mark Wielaard 2025-08-13 12:54:30 UTC
(In reply to mcermak from comment #3)
> Created attachment 184028 [details]
> proposed patch
> 
> Thank you for the review.  Updated patch attached.  Please check.

Looks good. Pushed as:

commit b306e8ef2771b03aad6440268c1940886d045576
Author: Martin Cermak <mcermak@redhat.com>
Date:   Wed Aug 13 09:03:13 2025 +0200

    PRE(sys_fchownat) not handling VKI_AT_FDCWD
    
    Multiple `make ltpchecks` failures seem tp be caused by
    PRE(sys_fchownat) not handling VKI_AT_FDCWD properly.
    This specifically impacts aarch64 test results these days.
    
    https://bugs.kde.org/show_bug.cgi?id=508154