[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 25/49] linux-user: Implement execveat
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v6 25/49] linux-user: Implement execveat |
Date: |
Sat, 19 Jan 2019 08:30:58 +1100 |
A trivial extension to our current execve implementation
to support the new(ish) syscall.
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall-defs.h | 1 +
linux-user/syscall-proc.inc.c | 19 ++++++++++++++-----
linux-user/syscall.c | 3 ++-
linux-user/strace.list | 3 ---
4 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h
index 58fef48666..392bd1579c 100644
--- a/linux-user/syscall-defs.h
+++ b/linux-user/syscall-defs.h
@@ -26,6 +26,7 @@ SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG);
#endif
SYSCALL_DEF(exit, ARG_DEC);
SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR);
+SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG);
#ifdef TARGET_NR_fork
SYSCALL_DEF(fork);
#endif
diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c
index 552aea60ae..699370c290 100644
--- a/linux-user/syscall-proc.inc.c
+++ b/linux-user/syscall-proc.inc.c
@@ -269,14 +269,13 @@ SYSCALL_IMPL(clone)
return do_clone(cpu_env, arg1, arg2, arg3, arg4, arg5);
}
-SYSCALL_IMPL(execve)
+static abi_long do_execveat(int dirfd, abi_ulong guest_path,
+ abi_ulong guest_argp, abi_ulong guest_envp,
+ int flags)
{
char **argp, **envp;
int argc, envc;
abi_ulong gp;
- abi_ulong guest_path = arg1;
- abi_ulong guest_argp = arg2;
- abi_ulong guest_envp = arg3;
abi_ulong addr;
char **q, *p;
int total_size = 0;
@@ -356,7 +355,7 @@ SYSCALL_IMPL(execve)
* before the execve completes and makes it the other
* program's problem.
*/
- ret = get_errno(safe_execve(p, argp, envp));
+ ret = get_errno(safe_execveat(dirfd, p, argp, envp, flags));
unlock_user(p, guest_path, 0);
execve_free:
@@ -379,6 +378,16 @@ SYSCALL_IMPL(execve)
return ret;
}
+SYSCALL_IMPL(execve)
+{
+ return do_execveat(AT_FDCWD, arg1, arg2, arg3, 0);
+}
+
+SYSCALL_IMPL(execveat)
+{
+ return do_execveat(arg1, arg2, arg3, arg4, arg5);
+}
+
SYSCALL_IMPL(exit)
{
CPUState *cpu = ENV_GET_CPU(cpu_env);
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9b5b2eb7f1..3a027651e3 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -682,7 +682,8 @@ safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int,
options, \
struct rusage *, rusage)
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)
safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds,
\
fd_set *, exceptfds, struct timespec *, timeout, void *, sig)
safe_syscall5(int, ppoll, struct pollfd *, ufds, unsigned int, nfds,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 8bc3fe6088..202bfa8f9e 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -139,9 +139,6 @@
#ifdef TARGET_NR_execv
{ TARGET_NR_execv, "execv" , NULL, print_execv, NULL },
#endif
-#ifdef TARGET_NR_execveat
-{ TARGET_NR_execveat, "execveat" , NULL, NULL, NULL },
-#endif
#ifdef TARGET_NR_exec_with_loader
{ TARGET_NR_exec_with_loader, "exec_with_loader" , NULL, NULL, NULL },
#endif
--
2.17.2
- [Qemu-devel] [PATCH v6 17/49] linux-user: Split out brk, (continued)
- [Qemu-devel] [PATCH v6 17/49] linux-user: Split out brk, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 14/49] linux-user: Split out ipc syscalls, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 18/49] linux-user: Split out clone, fork, vfork, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 19/49] linux-user: Split out wait4, waitid, waitpid, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 20/49] linux-user: Implement rusage argument to waitid, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 21/49] linux-user: Split out creat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 26/49] linux-user: Split out chdir, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 22/49] linux-user: Split out link, linkat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 24/49] linux-user: Split out execve, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 28/49] linux-user: Split out mknod, mknodat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 25/49] linux-user: Implement execveat,
Richard Henderson <=
- [Qemu-devel] [PATCH v6 23/49] linux-user: Split out unlink, unlinkat, rmdir, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 27/49] linux-user: Split out time, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 29/49] linux-user: Split out chmod, fchmod, fchmodat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 30/49] linux-user: Split out lseek, llseek, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 31/49] linux-user: Split out getpid, getppid, getxpid, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 33/49] linux-user: Split out umount, umount2, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 34/49] linux-user: Split out stime, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 32/49] linux-user: Split out mount, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 35/49] linux-user: Split out alarm, pause, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 36/49] linux-user: Split out utime, utimes, futimesat, Richard Henderson, 2019/01/18