Skip to contentSkip to conversation

sys_statx: support for statx(fd, NULL, AT_EMPTY_PATH)

PATCH New Miao Wang 1 participant 1 message Aug 23, 2024

lore
Share & tools
lore

Miao Wang

author
#0 lore raw

PATCH 1/1 sys_statx: support for statx(fd, NULL, AT_EMPTY_PATH)

statx(fd, NULL, AT_EMPTY_PATH) is supported since Linux 6.11 and this patch addes the support to valgrind, so that it won't complain when NULL is used as |filename| and |flags| includes AT_EMPTY_PATH.

Ref: commit 0ef625bba6fb ("vfs: support statx(..., NULL, AT_EMPTY_PATH, ...)")

---
 coregrind/m_syswrap/syswrap-linux.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
coregrind/m_syswrap/syswrap-linux.c +5 -1
index 9f3c51c17..453385599 100644
@@ -4209,8 +4209,12 @@ PRE(sys_statx)
    // 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;
+   Bool statx_null_path = (ARG2 == 0) && (ARG3 & VKI_AT_EMPTY_PATH);
    if (!both_filename_and_buf_are_null) {
-      PRE_MEM_RASCIIZ( "statx(filename)", ARG2 );
+      // Since Linux 6.11, the kernel allows passing a NULL filename when
+      // the AT_EMPTY_PATH flag is set.
+      if (!statx_null_path)
+         PRE_MEM_RASCIIZ( "statx(filename)", ARG2 );
       PRE_MEM_WRITE( "statx(buf)", ARG5, sizeof(struct vki_statx) );
    }
 }

---
base-commit: 61e44a4aef8775b925a7a91f403ebd7f4f6670a4
change-id: 20240824-statx-null-path-8eec6e0da3bc

Best regards,

Signature · 1 line
Miao Wang <[email protected]>