From de408f75bf28d76a0016325b75f14be45631472a Mon Sep 17 00:00:00 2001 From: Miao Wang Date: Mon, 26 Aug 2024 22:08:43 +0800 Subject: [PATCH] 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 adds 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, ...)") Signed-off-by: Miao Wang --- coregrind/m_syswrap/syswrap-linux.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 9f3c51c17..453385599 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -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) ); } } -- 2.47.2