diff options
author | Ananth N Mavinakayanahalli <ananth@in.ibm.com> | 2006-08-11 07:31:34 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-08-17 02:41:10 -0400 |
commit | 83db3dde2604d48e30a468c82da163dd1a8602b3 (patch) | |
tree | 6955ecdc6b0901da808686a2e9e07a3646008aac /arch | |
parent | b6f35b4966e0ae59cec45e5292b100698d12dc5f (diff) |
[POWERPC] kprobes: Fix possible system crash during out-of-line single-stepping
- On archs that have no-exec support, we vmalloc() a executable scratch
area of PAGE_SIZE and divide it up into an array of slots of maximum
instruction size for that arch
- On a kprobe registration, the original instruction is copied to the
first available free slot, so if multiple kprobes are registered, chances
are, they get contiguous slots
- On POWER4, due to not having coherent icaches, we could hit a situation
where a probe that is registered on one processor, is hit immediately on
another. This second processor could have fetched the stream of text from
the out-of-line single-stepping area *before* the probe registration
completed, possibly due to an earlier (and a different) kprobe hit and
hence would see stale data at the slot.
Executing such an arbitrary instruction lead to a problem as reported
in LTC bugzilla 23555.
The correct solution is to call flush_icache_range() as soon as the
instruction is copied for out-of-line single-stepping, so the correct
instruction is seen on all processors.
Thanks to Will Schmidt who tracked this down.
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Acked-by: Will Schmidt <will_schmidt@vnet.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/kprobes.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 9f0898c89759..cd65c367b8b6 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c | |||
@@ -61,6 +61,8 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) | |||
61 | if (!ret) { | 61 | if (!ret) { |
62 | memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); | 62 | memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); |
63 | p->opcode = *p->addr; | 63 | p->opcode = *p->addr; |
64 | flush_icache_range((unsigned long)p->ainsn.insn, | ||
65 | (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t)); | ||
64 | } | 66 | } |
65 | 67 | ||
66 | return ret; | 68 | return ret; |