diff options
author | Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 2007-05-11 12:38:40 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2007-05-11 12:38:40 -0400 |
commit | cdc7dbdfe6edac177acb32e4ca56b525d0743fe7 (patch) | |
tree | 739b21d116a24185eb1704cdcf64206043de2f20 /arch/ia64 | |
parent | 25d61578daae697c4a0eb817f42a868af9824f82 (diff) |
[IA64] fix Kprobes reentrancy
In case of reentrance i.e when a probe handler calls a functions which
inturn has a probe, we save a previous kprobe information and just single
step the reentrant probe without calling the actual probe handler. During
this reentracy period, if an interrupt occurs and if probe happens to
trigger in the inturrupt path, then we were corrupting the previous kprobe(
as we were overriding the previous kprobe info) info their by crashing the
system. This patch fixes this issues by having a an array of previous
kprobe info struct(with the array size of 2).
This similar technique is not needed on i386 and x86_64 because by default
interrupts are turn off in the break/int3 exception handler.
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64')
-rw-r--r-- | arch/ia64/kernel/kprobes.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c index 4f5fd0960ba7..72e593e94053 100644 --- a/arch/ia64/kernel/kprobes.c +++ b/arch/ia64/kernel/kprobes.c | |||
@@ -370,14 +370,18 @@ static int __kprobes valid_kprobe_addr(int template, int slot, | |||
370 | 370 | ||
371 | static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) | 371 | static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) |
372 | { | 372 | { |
373 | kcb->prev_kprobe.kp = kprobe_running(); | 373 | unsigned int i; |
374 | kcb->prev_kprobe.status = kcb->kprobe_status; | 374 | i = atomic_add_return(1, &kcb->prev_kprobe_index); |
375 | kcb->prev_kprobe[i-1].kp = kprobe_running(); | ||
376 | kcb->prev_kprobe[i-1].status = kcb->kprobe_status; | ||
375 | } | 377 | } |
376 | 378 | ||
377 | static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb) | 379 | static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb) |
378 | { | 380 | { |
379 | __get_cpu_var(current_kprobe) = kcb->prev_kprobe.kp; | 381 | unsigned int i; |
380 | kcb->kprobe_status = kcb->prev_kprobe.status; | 382 | i = atomic_sub_return(1, &kcb->prev_kprobe_index); |
383 | __get_cpu_var(current_kprobe) = kcb->prev_kprobe[i].kp; | ||
384 | kcb->kprobe_status = kcb->prev_kprobe[i].status; | ||
381 | } | 385 | } |
382 | 386 | ||
383 | static void __kprobes set_current_kprobe(struct kprobe *p, | 387 | static void __kprobes set_current_kprobe(struct kprobe *p, |