]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
PRE(sys_fchownat) not handling VKI_AT_FDCWD
authorMartin Cermak <mcermak@redhat.com>
Wed, 13 Aug 2025 07:03:13 +0000 (09:03 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 13 Aug 2025 12:51:22 +0000 (14:51 +0200)
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

NEWS
coregrind/m_syswrap/syswrap-linux.c

diff --git a/NEWS b/NEWS
index c754435d2b5b8e7b79bdacfd406a979b57ac2fe9..b5f8eeafe1932e5668eb16424048b57dcd5fdaf9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -78,6 +78,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 508029  Review the vmsplice syscall wrapper
 508030  Add several missing syscall hooks to ppc64-linux
 508093  VALGRIND_CLO_CHANGE does not update vex_control
+508154  PRE(sys_fchownat) not handling VKI_AT_FDCWD
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index ead6d9d59e8518ce5497fb23e151437c2693aad5..e6a57e2ade1c0f603e54bcd9230c67c8b65116d6 100644 (file)
@@ -6199,15 +6199,18 @@ PRE(sys_mknodat)
 
 PRE(sys_fchownat)
 {
+   Int arg_1 = (Int)ARG1;
+   const HChar *path = (const HChar*) ARG2;
    FUSE_COMPATIBLE_MAY_BLOCK();
-   PRINT("sys_fchownat ( %ld, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%"
-          FMT_REGWORD "x )", SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3, ARG4);
+   PRINT("sys_fchownat ( %d, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%"
+          FMT_REGWORD "x )", arg_1, ARG2, path, ARG3, ARG4);
    PRE_REG_READ4(long, "fchownat",
                  int, dfd, const char *, path,
                  vki_uid_t, owner, vki_gid_t, group);
    PRE_MEM_RASCIIZ( "fchownat(path)", ARG2 );
-   if ( !ML_(fd_allowed)(SARG1, "fchownat", tid, False) )
-     SET_STATUS_Failure( VKI_EBADF );
+   if ((ML_(safe_to_deref) (path, 1)) && (path[0] != '/'))
+      if ( (arg_1 != VKI_AT_FDCWD) && !ML_(fd_allowed)(arg_1, "fchownat", tid, False) )
+        SET_STATUS_Failure( VKI_EBADF );
 }
 
 PRE(sys_futimesat)