]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
sys_statx: don't complain if both |filename| and |buf| are NULL.
authorJulian Seward <jseward@acm.org>
Thu, 2 Jan 2020 13:27:24 +0000 (14:27 +0100)
committerJulian Seward <jseward@acm.org>
Thu, 2 Jan 2020 13:27:24 +0000 (14:27 +0100)
So as to work around the Rust library's dubious use of statx.

coregrind/m_syswrap/syswrap-linux.c

index 87c513a21717fd02447d4bf654eee197ebde2f9c..96c309e280f888659718573c3e5be71af4b0b8c2 100644 (file)
@@ -3692,10 +3692,19 @@ PRE(sys_statx)
    PRINT("sys_statx ( %ld, %#" FMT_REGWORD "x(%s), %ld, %ld, %#" FMT_REGWORD "x )",
          (Word)ARG1,ARG2,(char*)(Addr)ARG2,(Word)ARG3,(Word)ARG4,ARG5);
    PRE_REG_READ5(long, "statx",
-                 int, dirfd, char *, file_name, int, flags,
+                 int, dirfd, char *, filename, int, flags,
                  unsigned int, mask, struct statx *, buf);
-   PRE_MEM_RASCIIZ( "statx(file_name)", ARG2 );
-   PRE_MEM_WRITE( "statx(buf)", ARG5, sizeof(struct vki_statx) );
+   // Work around Rust's dubious use of statx, as described here:
+   // https://github.com/rust-lang/rust/blob/
+   //    ccd238309f9dce92a05a23c2959e2819668c69a4/
+   //    src/libstd/sys/unix/fs.rs#L128-L142
+   // in which it passes NULL for both filename and buf, and then looks at the
+   // return value, so as to determine whether or not this syscall is supported.
+   Bool both_filename_and_buf_are_null = ARG2 == 0 && ARG5 == 0;
+   if (!both_filename_and_buf_are_null) {
+      PRE_MEM_RASCIIZ( "statx(filename)", ARG2 );
+      PRE_MEM_WRITE( "statx(buf)", ARG5, sizeof(struct vki_statx) );
+   }
 }
 POST(sys_statx)
 {