mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 15:26:04 +00:00
Native hook: start a program again through /proc/self/exe as itself (#3120)
* Native hook: start a program again through /proc/self/exe as itself A program that execs /proc/self/exe (Chromium's network and utility services, Electron apps) reached the kernel link, which names ld.so, so the child was started without ld.so and saw libddexec as its own program. Chromium then looked for its ICU data beside libddexec and the network service crashed in a loop. The exec path now resolves /proc/self/exe to the program the hook knows it runs, so it is routed like any other guest program, and readlink of the exe link names a program from a bind by its guest path. * fix(hook): keep the host path of a running program a nested bind shadows
This commit is contained in:
1 parent
309893b722
commit
f6c6e73a6b
4 files changed
+54
-11
No files matched your search
@@ -10,6 +10,13 @@
|
||||
// PT_INTERP) literally and failed with "bad interpreter: No such file or directory".
|
||||
// getcwd() is not virtualised, so cwd + path is a real path that starts with DDNATV_ROOT.
|
||||
static const char *absolutize_exec_path(const char *path, char *buffer, size_t bufsize) {
|
||||
if (is_proc_self_exe(path)) {
|
||||
ssize_t n = handle_proc_self_exe(buffer, bufsize - 1);
|
||||
if (n > 0 && buffer[0] == '/') {
|
||||
buffer[n] = '\0';
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
if (!path || path[0] == '\0' || path[0] == '/') return path;
|
||||
char cwd[PATH_MAX];
|
||||
static char *(*real_getcwd)(char *, size_t) = NULL;
|
||||
|
||||
@@ -203,15 +203,10 @@ static void exe_from_cmdline(const char *cmdline_path, char *out, size_t outsz)
|
||||
}
|
||||
|
||||
static ssize_t copy_guest_exe(const char *real_exe, char *buf, size_t bufsiz) {
|
||||
const char *out_path = real_exe;
|
||||
if (g_ddnatv_root[0] != '\0') {
|
||||
size_t rlen = g_ddnatv_root_len;
|
||||
if (strncmp(real_exe, g_ddnatv_root, rlen) == 0 &&
|
||||
(real_exe[rlen] == '/' || real_exe[rlen] == '\0')) {
|
||||
out_path = real_exe + rlen;
|
||||
if (out_path[0] == '\0') out_path = "/";
|
||||
}
|
||||
}
|
||||
char guest[PATH_MAX];
|
||||
char back[PATH_MAX];
|
||||
const char *out_path = guest_path_of_host_dir(real_exe, guest, sizeof(guest));
|
||||
if (!out_path || strcmp(rewrite_path_in_root(out_path, back, sizeof(back)), real_exe) != 0) out_path = real_exe;
|
||||
size_t len = strlen(out_path);
|
||||
size_t copy_len = (len < bufsiz) ? len : bufsiz;
|
||||
memcpy(buf, out_path, copy_len);
|
||||
|
||||
Reference in new issue
Block a user