[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/5] linux-user: Fix the execfd case of /proc/self/exe open
From: |
YAMAMOTO Takashi |
Subject: |
[PATCH 3/5] linux-user: Fix the execfd case of /proc/self/exe open |
Date: |
Mon, 24 May 2021 13:54:09 +0900 |
It's problematic to return AT_EXECFD as it is because the user app
would close it.
This patch opens it via /proc/self/fd instead.
Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
---
linux-user/syscall.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a2b03ecb8b..14a63518e2 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8118,7 +8118,17 @@ static int do_openat(void *cpu_env, int dirfd, const
char *pathname, int flags,
if (is_proc_myself(pathname, "exe")) {
int execfd = qemu_getauxval(AT_EXECFD);
- return execfd ? execfd : safe_openat(dirfd, exec_path, flags, mode);
+ if (execfd) {
+ char filename[PATH_MAX];
+ int ret;
+
+ snprintf(filename, sizeof(filename), "/proc/self/fd/%d", execfd);
+ ret = safe_openat(dirfd, filename, flags, mode);
+ if (ret != -1) {
+ return ret;
+ }
+ }
+ return safe_openat(dirfd, exec_path, flags, mode);
}
for (fake_open = fakes; fake_open->filename; fake_open++) {
--
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, 2021/05/24
- [PATCH 3/5] linux-user: Fix the execfd case of /proc/self/exe open,
YAMAMOTO Takashi <=
- [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