[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/22] linux-user/syscall: Implement execveat()
From: |
Laurent Vivier |
Subject: |
[PULL 05/22] linux-user/syscall: Implement execveat() |
Date: |
Sat, 4 Feb 2023 17:08:13 +0100 |
From: Drew DeVault <sir@cmpwn.com>
References: https://gitlab.com/qemu-project/qemu/-/issues/1007
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20221104081015.706009-1-sir@cmpwn.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20221104173632.1052-6-philmd@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 11236d16a372..3e72bd333ede 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -696,7 +696,8 @@ safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int,
options, \
#endif
safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \
int, options, struct rusage *, rusage)
-safe_syscall3(int, execve, const char *, filename, char **, argv, char **,
envp)
+safe_syscall5(int, execveat, int, dirfd, const char *, filename,
+ char **, argv, char **, envp, int, flags)
#if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) || \
defined(TARGET_NR_pselect6) || defined(TARGET_NR_pselect6_time64)
safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds,
\
@@ -8357,9 +8358,9 @@ static int do_openat(CPUArchState *cpu_env, int dirfd,
const char *pathname, int
return safe_openat(dirfd, path(pathname), flags, mode);
}
-static int do_execve(CPUArchState *cpu_env,
+static int do_execveat(CPUArchState *cpu_env, int dirfd,
abi_long pathname, abi_long guest_argp,
- abi_long guest_envp)
+ abi_long guest_envp, int flags)
{
int ret;
char **argp, **envp;
@@ -8439,9 +8440,9 @@ static int do_execve(CPUArchState *cpu_env,
}
if (is_proc_myself(p, "exe")) {
- ret = get_errno(safe_execve(exec_path, argp, envp));
+ ret = get_errno(safe_execveat(dirfd, exec_path, argp, envp, flags));
} else {
- ret = get_errno(safe_execve(p, argp, envp));
+ ret = get_errno(safe_execveat(dirfd, p, argp, envp, flags));
}
unlock_user(p, pathname, 0);
@@ -8979,8 +8980,10 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int
num, abi_long arg1,
unlock_user(p, arg2, 0);
return ret;
#endif
+ case TARGET_NR_execveat:
+ return do_execveat(cpu_env, arg1, arg2, arg3, arg4, arg5);
case TARGET_NR_execve:
- return do_execve(cpu_env, arg1, arg2, arg3);
+ return do_execveat(cpu_env, AT_FDCWD, arg1, arg2, arg3, 0);
case TARGET_NR_chdir:
if (!(p = lock_user_string(arg1)))
return -TARGET_EFAULT;
--
2.39.1
- [PULL 10/22] Revert "linux-user: add more compat ioctl definitions", (continued)
- [PULL 10/22] Revert "linux-user: add more compat ioctl definitions", Laurent Vivier, 2023/02/04
- [PULL 17/22] linux-user: Improve strace output of personality() and sysinfo(), Laurent Vivier, 2023/02/04
- [PULL 15/22] linux-user: Fix SO_ERROR return code of getsockopt(), Laurent Vivier, 2023/02/04
- [PULL 11/22] Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h", Laurent Vivier, 2023/02/04
- [PULL 19/22] linux-user: Show 4th argument of rt_sigprocmask() in strace, Laurent Vivier, 2023/02/04
- [PULL 22/22] linux-user: Allow sendmsg() without IOV, Laurent Vivier, 2023/02/04
- [PULL 20/22] linux-user: Enhance strace output for various syscalls, Laurent Vivier, 2023/02/04
- [PULL 09/22] linux-user: add more netlink protocol constants, Laurent Vivier, 2023/02/04
- [PULL 03/22] linux-user/strace: Add output for execveat() syscall, Laurent Vivier, 2023/02/04
- [PULL 04/22] linux-user/syscall: Extract do_execve() from do_syscall1(), Laurent Vivier, 2023/02/04
- [PULL 05/22] linux-user/syscall: Implement execveat(),
Laurent Vivier <=
- [PULL 18/22] linux-user: Add emulation for MADV_WIPEONFORK and MADV_KEEPONFORK in madvise(), Laurent Vivier, 2023/02/04
- [PULL 16/22] linux-user: Fix /proc/cpuinfo output for hppa, Laurent Vivier, 2023/02/04
- [PULL 13/22] linux-user: Improve strace output of getgroups() and setgroups(), Laurent Vivier, 2023/02/04
- [PULL 21/22] linux-user: Implement SOL_ALG encryption support, Laurent Vivier, 2023/02/04
- [PULL 08/22] linux-user: fix strace build w/out munlockall, Laurent Vivier, 2023/02/04
- [PULL 14/22] linux-user: move target_flat.h to target subdirs, Laurent Vivier, 2023/02/04
- [PULL 12/22] linux-user: Add strace output for clock_getres_time64() and futex_time64(), Laurent Vivier, 2023/02/04
- Re: [PULL 00/22] Linux user for 8.0 patches, Peter Maydell, 2023/02/04