From 3d7532c9064a136b2fbd115ac667ba2079a5991a Mon Sep 17 00:00:00 2001 From: Pascal Zittlau Date: Tue, 16 Dec 2025 23:26:30 +0100 Subject: [PATCH] checked auxv for what to handle --- docs/TODO.md | 2 +- src/main.zig | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/TODO.md b/docs/TODO.md index 0326fdb..e2888d9 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -18,7 +18,7 @@ IvyBridge(2012) and AMD Zen 2 Family 17H(2019) and Linux 5.9(2020). - [x] `rt_sigreturn`: we can't use the normal `syscall` interception because we push something onto the stack, so `ucontext` isn't on top anymore. - [x] `/proc/self/exe`: intercept calls to `readlink`/`readlinkat` with that as argument -- [ ] `auxv`: check if that is setup correctly and completely +- [x] `auxv`: check if that is setup correctly and completely - [ ] JIT support: intercept `mmap`, `mprotect` and `mremap` that change pages to be executable - [ ] `SIGILL` patching fallback - [x] `vdso` handling diff --git a/src/main.zig b/src/main.zig index 19ddc99..a0e8bd8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -110,7 +110,6 @@ pub fn main() !void { var i: usize = 0; const auxv = std.os.linux.elf_aux_maybe.?; while (auxv[i].a_type != elf.AT_NULL) : (i += 1) { - // TODO: look at other auxv types and check if we need to change them. auxv[i].a_un.a_val = switch (auxv[i].a_type) { elf.AT_PHDR => base + ehdr.phoff, elf.AT_PHENT => ehdr.phentsize, @@ -123,6 +122,16 @@ pub fn main() !void { try patchLoadedElf(auxv[i].a_un.a_val); break :blk auxv[i].a_un.a_val; }, + elf.AT_EXECFD => { + @panic("Got AT_EXECFD auxv value"); + // TODO: handle AT_EXECFD, when needed + // The SysV ABI Specification says: + // > At process creation the system may pass control to an interpreter program. When + // > this happens, the system places either an entry of type AT_EXECFD or one of + // > type AT_PHDR in the auxiliary vector. The entry for type AT_EXECFD uses the + // > a_val member to contain a file descriptor open to read the application + // > program’s object file. + }, else => auxv[i].a_un.a_val, }; }