From e71e02caa7b89ec0de8caa5aeb6ac11c67726145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Christian=20C=C3=8ERSTEA?= Date: Mon, 29 Dec 2025 14:14:16 +0200 Subject: [PATCH] linux-user: allow null `pathname` for statx()/fstatat() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Linux 6.11, the path argument may be NULL. Before this patch, qemu-*-linux-user failed with EFAULT when `pathname` was specified as NULL, even for Linux kernel hosts > 6.10. This patch fixes this issue by checking whether `arg2` is 0. If so, don't return EFAULT, but instead perform the appropiate syscall and let the host's kernel handle null `pathname`. Cc: qemu-stable@nongnu.org Signed-off-by: Jean-Christian CÎRSTEA Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson Message-ID: <20251229121416.2209295-1-jean.christian.cirstea@gmail.com> (cherry picked from commit 82ae60c8b5cb98d610056a1e2d0ba72e9ef7907c) Signed-off-by: Michael Tokarev --- linux-user/syscall.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2060e561a2..ee7c34027e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12141,9 +12141,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, int dirfd = arg1; int flags = arg3; - p = lock_user_string(arg2); - if (p == NULL) { - return -TARGET_EFAULT; + p = NULL; + /* Since Linux 6.11, the path argument may be NULL */ + if (arg2 != 0) { + p = lock_user_string(arg2); + if (p == NULL) { + return -TARGET_EFAULT; + } } #if defined(__NR_statx) {