Skip to content

Commit e3e4d50

Browse files
thejhKAGA-KOKO
authored andcommitted
x86/kprobes: Stop calling fixup_exception() from kprobe_fault_handler()
This removes the call into exception fixup that was added in commit c28f896 ("[PATCH] kprobes: fix broken fault handling for x86_64"). On X86, kprobe_fault_handler() is called from two places: do_general_protection() (for #GP) and kprobes_fault() (for #PF). In both paths, the fixup_exception() call in the kprobe fault handler is redundant. In case of #GP, fixup_exception() is called immediately before kprobe_fault_handler() is invoked, so no need to try that again. This assumes that the kprobe's fault handler isn't going to do something crazy like changing RIP so that it suddenly points to an instruction that does userspace access. For #PF on a kernel address from kernel space, after the kprobe fault handler has run, no_context() is invoked, which calls fixup_exception(). Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Kees Cook <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: "Naveen N. Rao" <[email protected]> Cc: Anil S Keshavamurthy <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Alexander Viro <[email protected]> Cc: [email protected] Cc: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 76dee4a commit e3e4d50

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

arch/x86/kernel/kprobes/core.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,15 +1020,6 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
10201020
*/
10211021
if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
10221022
return 1;
1023-
1024-
/*
1025-
* In case the user-specified fault handler returned
1026-
* zero, try to fix up.
1027-
*/
1028-
if (fixup_exception(regs, trapnr))
1029-
return 1;
1030-
1031-
/* fixup routine could not handle it. */
10321023
}
10331024

10341025
return 0;

0 commit comments

Comments
 (0)