[patch 3/3] Text Edit Lock - kprobes i386

Mathieu Desnoyers
2007-06-18T22:06:49Z

[-- Attachment #1: text-edit-lock-kprobes-i386.patch --]
[-- Type: text/plain, Size: 1413 bytes --]

Kprobes can use the text edit lock to insure mutual exclusion when edition the
code and make sure the pages are writable.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
arch/i386/kernel/kprobes.c | 4 ++++
1 file changed, 4 insertions(+)

Index: linux-2.6-lttng/arch/i386/kernel/kprobes.c
===================================================================
--- linux-2.6-lttng.orig/arch/i386/kernel/kprobes.c 2007-06-18 17:41:27.000000000 -0400
+++ linux-2.6-lttng/arch/i386/kernel/kprobes.c 2007-06-18 17:41:31.000000000 -0400
@@ -169,14 +169,18 @@

void __kprobes arch_arm_kprobe(struct kprobe *p)
{
+ kernel_text_lock((unsigned long)p->addr, sizeof(kprobe_opcode_t));
*p->addr = BREAKPOINT_INSTRUCTION;
+ kernel_text_unlock((unsigned long)p->addr, sizeof(kprobe_opcode_t));
flush_icache_range((unsigned long) p->addr,
(unsigned long) p->addr + sizeof(kprobe_opcode_t));
}

void __kprobes arch_disarm_kprobe(struct kprobe *p)
{
+ kernel_text_lock((unsigned long)p->addr, sizeof(kprobe_opcode_t));
*p->addr = p->opcode;
+ kernel_text_unlock((unsigned long)p->addr, sizeof(kprobe_opcode_t));
flush_icache_range((unsigned long) p->addr,
(unsigned long) p->addr + sizeof(kprobe_opcode_t));