fix(nativeguest): x86-64 path calls, SIGSYS handlers and re-execs stay inside the rootfs hook (#3074)

* fix(nativeguest): x86-64 path system calls and SIGSYS handlers stay inside the rootfs hook

FEX passed most guest path system calls to the kernel with an inline svc, so the
native path hook never mapped them, and it mirrored guest SIGSYS handlers with a
raw rt_sigaction that replaced the hook's own handler, after which the next
blocked system call killed the program. Path calls now go through libc's
syscall(), which the hook maps (guarded until the hook is initialised so an early
allocator cannot deadlock), and a SIGSYS handler set through syscall() is
recorded and chained like one set through sigaction().

* fix(ddexec): a program that re-execs itself keeps the rootfs hook

A re-exec through /proc/self/exe starts the program through the guest
ld.so again but left out the hook, so the child saw host paths. Steam's
reaper then recorded host install folders, and Battle.net games moved to
a mapped drive the Library could not resolve. The re-exec now preloads
the hook of the root the same way the first start does.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-23 11:11:10 -05:00
1 parent bf7f7ecda7
commit 823f70320f
11 files changed
+942 -52

No files matched your search

+19 -3
View File
@@ -15,24 +15,27 @@ RECORDER = r"""
#define _GNU_SOURCE
#include <spawn.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static void show(const char *path, char *const argv[]) {
static void show(const char *path, char *const argv[], char *const envp[]) {
printf("call\t%s", path);
for (int i = 0; argv[i]; i++) printf("\t%s", argv[i]);
printf("\n");
for (int i = 0; envp && envp[i]; i++)
if (strncmp(envp[i], "DDNATV_LIBRARY_PATH=", 20) == 0) printf("libpath\t%s\n", envp[i] + 20);
fflush(stdout);
}
int posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *actions,
const posix_spawnattr_t *attr, char *const argv[], char *const envp[]) {
show(path, argv);
show(path, argv, envp);
if (pid) *pid = 1;
return 0;
}
int execve(const char *path, char *const argv[], char *const envp[]) {
show(path, argv);
show(path, argv, envp);
_exit(0);
}
"""
@@ -114,6 +117,7 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
env.update(hook_env)
out = subprocess.run(cmd + [str(self.probe), how, *argv], env=env, capture_output=True, text=True, timeout=120)
calls = [line.split("\t")[1:] for line in out.stdout.splitlines() if line.startswith("call\t")]
self.library_paths = [line.split("\t", 1)[1] for line in out.stdout.splitlines() if line.startswith("libpath\t")]
self.assertEqual(1, len(calls), out.stdout + out.stderr)
if how == "spawn":
self.assertIn("ret\t0", out.stdout.splitlines(), out.stdout + out.stderr)
@@ -142,6 +146,18 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
def test_spawn_and_exec_start_a_dynamic_program_the_same_way(self):
self.assertEqual(self.call("exec", GUEST_TOOL, "x"), self.call("spawn", GUEST_TOOL, "x"))
def test_a_program_started_through_ldso_records_its_library_path(self):
for how in ("exec", "spawn"):
with self.subTest(how=how):
argv = self.call(how, GUEST_TOOL, "x")[1:]
self.assertEqual([argv[argv.index("--library-path") + 1]], self.library_paths)
def test_ldso_started_by_name_records_no_library_path(self):
for how in ("exec", "spawn"):
with self.subTest(how=how):
self.call(how, GUEST_LDSO, "--list", GUEST_TOOL)
self.assertEqual([], self.library_paths)
if __name__ == "__main__":
unittest.main()