Skip to content

Commit c026b35

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
x86, mm, perf: Allow recursive faults from interrupts
Waiman managed to trigger a PMI while in a emulate_vsyscall() fault, the PMI in turn managed to trigger a fault while obtaining a stack trace. This triggered the sig_on_uaccess_error recursive fault logic and killed the process dead. Fix this by explicitly excluding interrupts from the recursive fault logic. Reported-and-Tested-by: Waiman Long <[email protected]> Fixes: e00b12e ("perf/x86: Further optimize copy_from_user_nmi()") Cc: Aswin Chandramouleeswaran <[email protected]> Cc: Scott J Norton <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 85ce70f commit c026b35

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

arch/x86/mm/fault.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,20 @@ no_context(struct pt_regs *regs, unsigned long error_code,
641641

642642
/* Are we prepared to handle this kernel fault? */
643643
if (fixup_exception(regs)) {
644+
/*
645+
* Any interrupt that takes a fault gets the fixup. This makes
646+
* the below recursive fault logic only apply to a faults from
647+
* task context.
648+
*/
649+
if (in_interrupt())
650+
return;
651+
652+
/*
653+
* Per the above we're !in_interrupt(), aka. task context.
654+
*
655+
* In this case we need to make sure we're not recursively
656+
* faulting through the emulate_vsyscall() logic.
657+
*/
644658
if (current_thread_info()->sig_on_uaccess_error && signal) {
645659
tsk->thread.trap_nr = X86_TRAP_PF;
646660
tsk->thread.error_code = error_code | PF_USER;
@@ -649,6 +663,10 @@ no_context(struct pt_regs *regs, unsigned long error_code,
649663
/* XXX: hwpoison faults will set the wrong code. */
650664
force_sig_info_fault(signal, si_code, address, tsk, 0);
651665
}
666+
667+
/*
668+
* Barring that, we can do the fixup and be happy.
669+
*/
652670
return;
653671
}
654672

0 commit comments

Comments
 (0)