Skip to content

Commit 1904be1

Browse files
committed
tracing: Do not allow stack_tracer to record stack in NMI
The code in stack tracer should not be executed within an NMI as it grabs spinlocks and stack tracing an NMI gives the possibility of causing a deadlock. Although this is safe on x86_64, because it does not perform stack traces when the task struct stack is not in use (interrupts and NMIs), it may be an issue for NMIs on i386 and other archs that use the same stack as the NMI. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent a2d7629 commit 1904be1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎kernel/trace/trace_stack.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ check_stack(unsigned long ip, unsigned long *stack)
8585
if (!object_is_on_stack(stack))
8686
return;
8787

88+
/* Can't do this from NMI context (can cause deadlocks) */
89+
if (in_nmi())
90+
return;
91+
8892
local_irq_save(flags);
8993
arch_spin_lock(&max_stack_lock);
9094

0 commit comments

Comments
 (0)