Skip to content

Commit 247ed9e

Browse files
benzeajmberg-intel
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent b76d18b commit 247ed9e

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

arch/um/os-Linux/skas/process.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,6 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi)
163163
memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
164164
}
165165

166-
static void handle_segv(int pid, struct uml_pt_regs *regs)
167-
{
168-
get_skas_faultinfo(pid, &regs->faultinfo);
169-
segv(regs->faultinfo, 0, 1, NULL, NULL);
170-
}
171-
172166
static void handle_trap(int pid, struct uml_pt_regs *regs)
173167
{
174168
if ((UPT_IP(regs) >= STUB_START) && (UPT_IP(regs) < STUB_END))
@@ -521,13 +515,14 @@ void userspace(struct uml_pt_regs *regs)
521515

522516
switch (sig) {
523517
case SIGSEGV:
524-
if (PTRACE_FULL_FAULTINFO) {
525-
get_skas_faultinfo(pid,
526-
&regs->faultinfo);
518+
get_skas_faultinfo(pid, &regs->faultinfo);
519+
520+
if (PTRACE_FULL_FAULTINFO)
527521
(*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si,
528522
regs, NULL);
529-
}
530-
else handle_segv(pid, regs);
523+
else
524+
segv(regs->faultinfo, 0, 1, NULL, NULL);
525+
531526
break;
532527
case SIGTRAP + 0x80:
533528
handle_trap(pid, regs);

0 commit comments

Comments
 (0)