mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
[PATCH] kprobes: fix bug when probed on task and isr functions
This patch fixes a race condition where in system used to hang or sometime crash within minutes when kprobes are inserted on ISR routine and a task routine. The fix has been stress tested on i386, ia64, pp64 and on x86_64. To reproduce the problem insert kprobes on schedule() and do_IRQ() functions and you should see hang or system crash. Signed-off-by: Anil S Keshavamurthy <[email protected]> Signed-off-by: Ananth N Mavinakayanahalli <[email protected]> Acked-by: Prasanna S Panchamukhi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
bce0649417
commit
deac66ae45
7 changed files with 55 additions and 10 deletions
|
|
@ -155,14 +155,36 @@ void __kprobes free_insn_slot(kprobe_opcode_t *slot)
|
|||
/* Locks kprobe: irqs must be disabled */
|
||||
void __kprobes lock_kprobes(void)
|
||||
{
|
||||
unsigned long flags = 0;
|
||||
|
||||
/* Avoiding local interrupts to happen right after we take the kprobe_lock
|
||||
* and before we get a chance to update kprobe_cpu, this to prevent
|
||||
* deadlock when we have a kprobe on ISR routine and a kprobe on task
|
||||
* routine
|
||||
*/
|
||||
local_irq_save(flags);
|
||||
|
||||
spin_lock(&kprobe_lock);
|
||||
kprobe_cpu = smp_processor_id();
|
||||
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
void __kprobes unlock_kprobes(void)
|
||||
{
|
||||
unsigned long flags = 0;
|
||||
|
||||
/* Avoiding local interrupts to happen right after we update
|
||||
* kprobe_cpu and before we get a a chance to release kprobe_lock,
|
||||
* this to prevent deadlock when we have a kprobe on ISR routine and
|
||||
* a kprobe on task routine
|
||||
*/
|
||||
local_irq_save(flags);
|
||||
|
||||
kprobe_cpu = NR_CPUS;
|
||||
spin_unlock(&kprobe_lock);
|
||||
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
/* You have to be holding the kprobe_lock */
|
||||
|
|
|
|||
Loading…
Reference in a new issue