Files
Ivan Gotovchits 3d4d214f51 arch: allow partial PTRACE_GETREGSET NT_PRSTATUS reads
The Linux kernel's ptrace_regset() (kernel/ptrace.c) writes
min(iov_len, actual_size) bytes and returns success for any non-zero
buffer; it never rejects a PTRACE_GETREGSET request solely because the
buffer is smaller than the full register set.

gVisor's PtraceGetRegSet previously returned EFAULT when maxlen was
less than ptraceRegistersSize on both x86 and arm64.  This broke any
tool that passes a smaller buffer, most notably libunwind which passes
sizeof(gregset_t) = 184 bytes rather than sizeof(user_regs_struct) = 216
bytes for the PTRACE_GETREGSET call, causing unw_init_remote() to fail
with UNW_EBADREG and making ptrace-based stack unwinding non-functional
inside gVisor containers.

Fix PtraceGetRegSet on x86 and arm64 to write min(maxlen,
ptraceRegistersSize) bytes when maxlen is positive but smaller than the
full register set, matching Linux kernel semantics.  Add a syscall test
that exercises the partial read path and verifies the bytes written match
the corresponding bytes from a full register read.

Signed-off-by: Ivan Gotovchits <[email protected]>
2026-04-22 22:57:34 -04:00
..
…
…
…
…