]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user: allow null `pathname` for statx()/fstatat()
authorJean-Christian CÎRSTEA <jean.christian.cirstea@gmail.com>
Mon, 29 Dec 2025 12:14:16 +0000 (14:14 +0200)
committerRichard Henderson <richard.henderson@linaro.org>
Sun, 11 Jan 2026 21:49:33 +0000 (08:49 +1100)
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 <jean.christian.cirstea@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20251229121416.2209295-1-jean.christian.cirstea@gmail.com>

linux-user/syscall.c

index 2060e561a20314d419a8efd700b7d7cc3bfe45cf..ee7c34027e0ffef0a898973b9bf345039f20b057 100644 (file)
@@ -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)
             {