mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-11 06:28:06 +07:00
kprobes: Skip kretprobe hit in NMI context to avoid deadlock
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 <masami.hiramatsu.pt@hitachi.com> Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: David S. Miller <davem@davemloft.net> Link: http://lkml.kernel.org/r/20140804031016.11433.65539.stgit@kbuild-fedora.novalocal [ Minor edits for clarity. ] Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
98a96f2022
commit
f96f56780c
@ -1778,6 +1778,17 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
|
|||||||
unsigned long hash, flags = 0;
|
unsigned long hash, flags = 0;
|
||||||
struct kretprobe_instance *ri;
|
struct kretprobe_instance *ri;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 */
|
/* TODO: consider to only swap the RA after the last pre_handler fired */
|
||||||
hash = hash_ptr(current, KPROBE_HASH_BITS);
|
hash = hash_ptr(current, KPROBE_HASH_BITS);
|
||||||
raw_spin_lock_irqsave(&rp->lock, flags);
|
raw_spin_lock_irqsave(&rp->lock, flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user