]> Git Repo - linux.git/commitdiff
kprobes: Skip kretprobe hit in NMI context to avoid deadlock
authorMasami Hiramatsu <[email protected]>
Mon, 4 Aug 2014 03:10:16 +0000 (03:10 +0000)
committerIngo Molnar <[email protected]>
Fri, 8 Aug 2014 08:38:04 +0000 (10:38 +0200)
Skip kretprobe hit in NMI context, because if an NMI happens
inside the critical section protected by kretprobe_table.lock
and another(or same) kretprobe hit, pre_kretprobe_handler
tries to lock kretprobe_table.lock again.
Normal interrupts have no problem because they are disabled
with the lock.

Signed-off-by: Masami Hiramatsu <[email protected]>
Acked-by: Ananth N Mavinakayanahalli <[email protected]>
Cc: David S. Miller <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ Minor edits for clarity. ]
Signed-off-by: Ingo Molnar <[email protected]>
kernel/kprobes.c

index 734e9a7d280bd22a046566cc40b1edf159f250bf..3995f546d0f3f9c7bc845e7053f7a099088108a2 100644 (file)
@@ -1778,7 +1778,18 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
        unsigned long hash, flags = 0;
        struct kretprobe_instance *ri;
 
-       /*TODO: consider to only swap the RA after the last pre_handler fired */
+       /*
+        * To avoid deadlocks, prohibit return probing in NMI contexts,
+        * just skip the probe and increase the (inexact) 'nmissed'
+        * statistical counter, so that the user is informed that
+        * something happened:
+        */
+       if (unlikely(in_nmi())) {
+               rp->nmissed++;
+               return 0;
+       }
+
+       /* TODO: consider to only swap the RA after the last pre_handler fired */
        hash = hash_ptr(current, KPROBE_HASH_BITS);
        raw_spin_lock_irqsave(&rp->lock, flags);
        if (!hlist_empty(&rp->free_instances)) {
This page took 0.068438 seconds and 4 git commands to generate.