[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 7/8] linux-user: Implement faccessat2
From: |
Laurent Vivier |
Subject: |
[PULL 7/8] linux-user: Implement faccessat2 |
Date: |
Tue, 25 Oct 2022 09:36:05 +0200 |
From: WANG Xuerui <xen0n@gentoo.org>
User space has been preferring this syscall for a while, due to its
closer match with C semantics, and newer platforms such as LoongArch
apparently have libc implementations that don't fallback to faccessat
so normal access checks are failing without the emulation in place.
Tested by successfully emerging several packages within a Gentoo loong
stage3 chroot, emulated on amd64 with help of static qemu-loongarch64.
Reported-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
Message-Id: <20221009060813.2289077-1-xen0n@gentoo.org>
[lv: removing defined(__NR_faccessat2) in syscall.c,
adding defined(TARGET_NR_faccessat2) on print_faccessat()]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/strace.c | 2 +-
linux-user/strace.list | 3 +++
linux-user/syscall.c | 9 +++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 86c081c83f74..9ae5a812cd71 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1969,7 +1969,7 @@ print_execv(CPUArchState *cpu_env, const struct
syscallname *name,
}
#endif
-#ifdef TARGET_NR_faccessat
+#if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2)
static void
print_faccessat(CPUArchState *cpu_env, const struct syscallname *name,
abi_long arg0, abi_long arg1, abi_long arg2,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index a87415bf3d50..3df2184580aa 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -178,6 +178,9 @@
#ifdef TARGET_NR_faccessat
{ TARGET_NR_faccessat, "faccessat" , NULL, print_faccessat, NULL },
#endif
+#ifdef TARGET_NR_faccessat2
+{ TARGET_NR_faccessat2, "faccessat2" , NULL, print_faccessat, NULL },
+#endif
#ifdef TARGET_NR_fadvise64
{ TARGET_NR_fadvise64, "fadvise64" , NULL, NULL, NULL },
#endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d499cac1d5d1..e985ad167f21 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9143,6 +9143,15 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int
num, abi_long arg1,
unlock_user(p, arg2, 0);
return ret;
#endif
+#if defined(TARGET_NR_faccessat2)
+ case TARGET_NR_faccessat2:
+ if (!(p = lock_user_string(arg2))) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(faccessat(arg1, p, arg3, arg4));
+ unlock_user(p, arg2, 0);
+ return ret;
+#endif
#ifdef TARGET_NR_nice /* not on alpha */
case TARGET_NR_nice:
return get_errno(nice(arg1));
--
2.37.3
- [PULL 0/8] Linux user for 7.2 patches, Laurent Vivier, 2022/10/25
- [PULL 2/8] linux-user: fix pidfd_send_signal(), Laurent Vivier, 2022/10/25
- [PULL 4/8] linux-user: don't use AT_EXECFD in do_openat(), Laurent Vivier, 2022/10/25
- [PULL 5/8] linux-user: add more compat ioctl definitions, Laurent Vivier, 2022/10/25
- [PULL 8/8] linux-user: Add guest memory layout to exception dump, Laurent Vivier, 2022/10/25
- [PULL 3/8] linux-user: handle /proc/self/exe with execve() syscall, Laurent Vivier, 2022/10/25
- [PULL 6/8] linux-user: remove conditionals for many fs.h ioctls, Laurent Vivier, 2022/10/25
- [PULL 7/8] linux-user: Implement faccessat2,
Laurent Vivier <=
- [PULL 1/8] linux-user: Fix more MIPS n32 syscall ABI issues, Laurent Vivier, 2022/10/25
- Re: [PULL 0/8] Linux user for 7.2 patches, Stefan Hajnoczi, 2022/10/26