From: Benjamin Berg Date: Mon, 2 Jun 2025 13:00:46 +0000 (+0200) Subject: um: Move faultinfo extraction into userspace routine X-Git-Tag: v6.16-rc1~38^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=247ed9e4a6869f3bf07bffd277a341a6833abdbc;p=thirdparty%2Flinux.git um: Move faultinfo extraction into userspace routine The segv handler is called slightly differently depending on whether PTRACE_FULL_FAULTINFO is set or not (32bit vs. 64bit). The only difference is that we don't try to pass the registers and instruction pointer to the segv handler. It would be good to either document or remove the difference, but I do not know why this difference exists. And, passing NULL can even result in a crash. Signed-off-by: Benjamin Berg Link: https://patch.msgid.link/20250602130052.545733-2-benjamin@sipsolutions.net Signed-off-by: Johannes Berg --- diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index ae2aea062f06..97c2f964f5fc 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -163,12 +163,6 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi) memcpy(fi, (void *)current_stub_stack(), sizeof(*fi)); } -static void handle_segv(int pid, struct uml_pt_regs *regs) -{ - get_skas_faultinfo(pid, ®s->faultinfo); - segv(regs->faultinfo, 0, 1, NULL, NULL); -} - static void handle_trap(int pid, struct uml_pt_regs *regs) { if ((UPT_IP(regs) >= STUB_START) && (UPT_IP(regs) < STUB_END)) @@ -521,13 +515,14 @@ void userspace(struct uml_pt_regs *regs) switch (sig) { case SIGSEGV: - if (PTRACE_FULL_FAULTINFO) { - get_skas_faultinfo(pid, - ®s->faultinfo); + get_skas_faultinfo(pid, ®s->faultinfo); + + if (PTRACE_FULL_FAULTINFO) (*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si, regs, NULL); - } - else handle_segv(pid, regs); + else + segv(regs->faultinfo, 0, 1, NULL, NULL); + break; case SIGTRAP + 0x80: handle_trap(pid, regs);