From: Jean-Christian CÎRSTEA <[email protected]> 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: [email protected] Signed-off-by: Jean-Christian CÎRSTEA <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-ID: <[email protected]> (cherry picked from commit 82ae60c8b5cb98d610056a1e2d0ba72e9ef7907c) Signed-off-by: Michael Tokarev <[email protected]> diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dcca90cfee..77bdbf20ae 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11908,9 +11908,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) { -- 2.47.3
