[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/5] linux-uesr: make exec_path realpath
From: |
YAMAMOTO Takashi |
Subject: |
[PATCH 2/5] linux-uesr: make exec_path realpath |
Date: |
Mon, 24 May 2021 13:54:08 +0900 |
Otherwise, it can be easily fooled by the user app using chdir().
Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
---
linux-user/main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 4dfc47ad3b..1f9f4e3820 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -55,6 +55,7 @@
#endif
char *exec_path;
+char exec_path_store[PATH_MAX];
int singlestep;
static const char *argv0;
@@ -610,7 +611,10 @@ static int parse_args(int argc, char **argv)
exit(EXIT_FAILURE);
}
- exec_path = argv[optind];
+ exec_path = realpath(argv[optind], exec_path_store);
+ if (exec_path == NULL) {
+ exec_path = argv[optind];
+ }
return optind;
}
--
2.21.1 (Apple Git-122.3)
- [PATCH 0/5] linux-user changes to run docker, YAMAMOTO Takashi, 2021/05/24
- [PATCH 2/5] linux-uesr: make exec_path realpath,
YAMAMOTO Takashi <=
- [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, 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