diff options
Diffstat (limited to 'kernel/kprobes.c')
-rw-r--r-- | kernel/kprobes.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 3b7653f2e7ae..f3ea492ab44d 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -155,14 +155,36 @@ void __kprobes free_insn_slot(kprobe_opcode_t *slot) | |||
155 | /* Locks kprobe: irqs must be disabled */ | 155 | /* Locks kprobe: irqs must be disabled */ |
156 | void __kprobes lock_kprobes(void) | 156 | void __kprobes lock_kprobes(void) |
157 | { | 157 | { |
158 | unsigned long flags = 0; | ||
159 | |||
160 | /* Avoiding local interrupts to happen right after we take the kprobe_lock | ||
161 | * and before we get a chance to update kprobe_cpu, this to prevent | ||
162 | * deadlock when we have a kprobe on ISR routine and a kprobe on task | ||
163 | * routine | ||
164 | */ | ||
165 | local_irq_save(flags); | ||
166 | |||
158 | spin_lock(&kprobe_lock); | 167 | spin_lock(&kprobe_lock); |
159 | kprobe_cpu = smp_processor_id(); | 168 | kprobe_cpu = smp_processor_id(); |
169 | |||
170 | local_irq_restore(flags); | ||
160 | } | 171 | } |
161 | 172 | ||
162 | void __kprobes unlock_kprobes(void) | 173 | void __kprobes unlock_kprobes(void) |
163 | { | 174 | { |
175 | unsigned long flags = 0; | ||
176 | |||
177 | /* Avoiding local interrupts to happen right after we update | ||
178 | * kprobe_cpu and before we get a a chance to release kprobe_lock, | ||
179 | * this to prevent deadlock when we have a kprobe on ISR routine and | ||
180 | * a kprobe on task routine | ||
181 | */ | ||
182 | local_irq_save(flags); | ||
183 | |||
164 | kprobe_cpu = NR_CPUS; | 184 | kprobe_cpu = NR_CPUS; |
165 | spin_unlock(&kprobe_lock); | 185 | spin_unlock(&kprobe_lock); |
186 | |||
187 | local_irq_restore(flags); | ||
166 | } | 188 | } |
167 | 189 | ||
168 | /* You have to be holding the kprobe_lock */ | 190 | /* You have to be holding the kprobe_lock */ |