[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] linux-user: handle /proc/self/exe for execve
From: |
YAMAMOTO Takashi |
Subject: |
[PATCH 1/5] linux-user: handle /proc/self/exe for execve |
Date: |
Mon, 24 May 2021 13:54:07 +0900 |
It seems somehow common to execve /proc/self/exe in docker
or golang community these days.
At least, moby "reexec" and runc "libcontainer" do that.
Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
---
linux-user/syscall.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c9f812091c..a2b03ecb8b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8470,6 +8470,7 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
#endif
case TARGET_NR_execve:
{
+ const char *path;
char **argp, **envp;
int argc, envc;
abi_ulong gp;
@@ -8537,7 +8538,11 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
* before the execve completes and makes it the other
* program's problem.
*/
- ret = get_errno(safe_execve(p, argp, envp));
+ path = p;
+ if (is_proc_myself(path, "exe")) {
+ path = exec_path;
+ }
+ ret = get_errno(safe_execve(path, argp, envp));
unlock_user(p, arg1, 0);
goto execve_end;
--
2.21.1 (Apple Git-122.3)
- [PATCH 0/5] linux-user changes to run docker, YAMAMOTO Takashi, 2021/05/24
- [PATCH 1/5] linux-user: handle /proc/self/exe for execve,
YAMAMOTO Takashi <=
- [PATCH 3/5] linux-user: Fix the execfd case of /proc/self/exe open, YAMAMOTO Takashi, 2021/05/24
- [PATCH 4/5] linux-user: dup the execfd on start up, YAMAMOTO Takashi, 2021/05/24
- [PATCH 5/5] linux-user: Implement pivot_root, YAMAMOTO Takashi, 2021/05/24
- Re: [PATCH 0/5] linux-user changes to run docker, Alex Bennée, 2021/05/24