From: Mike Hommey Date: Fri, 26 Feb 2021 08:09:52 +0000 (+0900) Subject: sys_newfstatat: don't complain if |file_name| is NULL. X-Git-Tag: VALGRIND_3_17_0~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d45e212a66fe83f593693adf452d4ea78dcf1d3;p=thirdparty%2Fvalgrind.git sys_newfstatat: don't complain if |file_name| is NULL. This is a followup to 2a7d3ae76, in the case rust code runs against a glibc that supports statx but a kernel that doesn't, in which case glibc falls back to fstatat. https://bugs.kde.org/show_bug.cgi?id=433641 --- diff --git a/NEWS b/NEWS index 19118b9dc7..43533fc1ad 100644 --- a/NEWS +++ b/NEWS @@ -141,6 +141,7 @@ where XXXXXX is the bug number as listed below. 433323 Use pkglibexecdir as vglibdir 433500 DRD regtest faulures when libstdc++ and libgcc debuginfo are installed 433629 valgrind/README has type "abd" instead of "and" +433641 Rust std::sys::unix::fs::try_statx Syscall param fstatat(file_name) n-i-bz helgrind: If hg_cli__realloc fails, return NULL. diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 3d6939d147..5ae4e66132 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -5885,8 +5885,14 @@ PRE(sys_newfstatat) SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3); PRE_REG_READ3(long, "fstatat", int, dfd, char *, file_name, struct stat *, buf); - PRE_MEM_RASCIIZ( "fstatat(file_name)", ARG2 ); - PRE_MEM_WRITE( "fstatat(buf)", ARG3, sizeof(struct vki_stat) ); + // See the comment about Rust in PRE(sys_statx). When glibc does support + // statx rust uses that instead of the system call, but glibc's statx is + // implemented in terms of fstatat, so the filename being NULL is + // transferred here. + if (ARG2 != 0) { + PRE_MEM_RASCIIZ( "fstatat(file_name)", ARG2 ); + PRE_MEM_WRITE( "fstatat(buf)", ARG3, sizeof(struct vki_stat) ); + } } POST(sys_newfstatat)