From: Martin Cermak Date: Wed, 13 Aug 2025 07:03:13 +0000 (+0200) Subject: PRE(sys_fchownat) not handling VKI_AT_FDCWD X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b306e8ef2771b03aad6440268c1940886d045576;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/NEWS b/NEWS index c754435d2..b5f8eeafe 100644 --- 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 diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index ead6d9d59..e6a57e2ad 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -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)