Re: [patch 3/3] Text Edit Lock - kprobes i386
This suggestion looks more like a workaround to get rid of a bigger issue. If we do that, we have to use CONFIG_* exclusivity for either (ro-data protection) or (paravirt, kprobes, immediate values). One big advantage of my patch is that we can remove weird exclusivity cases involving paravirt and cpu hotplug, like this one: -#ifndef CONFIG_KPROBES -#ifdef CONFIG_HOTPLUG_CPU - /* It must still be possible to apply SMP alternatives. */ - if (num_possible_cpus() <= 1) -#endif - { - change_page_attr(virt_to_page(start), -size >> PAGE_SHIFT, PAGE_KERNEL_RX); - printk("Write protecting the kernel text: %luk\n", size >> 10); - kernel_text_is_ro = 1; - } Mathieu * S. P. Prasanna ([EMAIL PROTECTED]) wrote: > On Tue, Jul 03, 2007 at 12:38:22PM -0400, Mathieu Desnoyers wrote: > > Kprobes can use the text edit lock to insure mutual exclusion when edition > > the > > code and make sure the pages are writable. > > Linus suggested for splitting ro-data and ro-text; And allow ro-text > only if kprobes is not configured. > Please see the discussion thread, URL given below > http://lkml.org/lkml/2007/6/20/436 > > This patch below allows to configure and mark the kernel text and > kernel data as read-only separately. Also kernel text > is configured read-only if kprobes is not configured. > > Thanks > Prasanna > > This patch allows to configure and mark the kernel text and > kernel data as read-only separately. > > Signed-off-by: Prasanna S P. <[EMAIL PROTECTED]> > > > arch/i386/Kconfig.debug |8 > arch/i386/mm/init.c | 22 -- > 2 files changed, 24 insertions(+), 6 deletions(-) > > diff -puN arch/i386/Kconfig.debug~mark-kernel-text-data-ro-seperately-i386 > arch/i386/Kconfig.debug > --- > linux-2.6.22-rc6/arch/i386/Kconfig.debug~mark-kernel-text-data-ro-seperately-i386 > 2007-07-04 13:45:24.0 +0530 > +++ linux-2.6.22-rc6-prasanna/arch/i386/Kconfig.debug 2007-07-04 > 13:52:31.0 +0530 > @@ -56,6 +56,14 @@ config DEBUG_RODATA > portion of the kernel code won't be covered by a 2MB TLB anymore. > If in doubt, say "N". > > +config DEBUG_ROTEXT > + bool "Write protect kernel text" > + depends on DEBUG_RODATA && !KPROBES > + help > + Mark the kernel text as write-protected in the pagetables. > + Only allow this if kprobes is not configured. > + If in doubt, say "N". > + > config 4KSTACKS > bool "Use 4Kb for kernel stacks instead of 8Kb" > depends on DEBUG_KERNEL > diff -puN arch/i386/mm/init.c~mark-kernel-text-data-ro-seperately-i386 > arch/i386/mm/init.c > --- > linux-2.6.22-rc6/arch/i386/mm/init.c~mark-kernel-text-data-ro-seperately-i386 > 2007-07-04 13:45:24.0 +0530 > +++ linux-2.6.22-rc6-prasanna/arch/i386/mm/init.c 2007-07-04 > 13:51:39.0 +0530 > @@ -792,14 +792,11 @@ static int noinline do_test_wp_bit(void) > return flag; > } > > -#ifdef CONFIG_DEBUG_RODATA > - > -void mark_rodata_ro(void) > +static inline void mark_rwtext_ro(void) > { > unsigned long start = PFN_ALIGN(_text); > unsigned long size = PFN_ALIGN(_etext) - start; > > -#ifndef CONFIG_KPROBES > #ifdef CONFIG_HOTPLUG_CPU > /* It must still be possible to apply SMP alternatives. */ > if (num_possible_cpus() <= 1) > @@ -809,9 +806,22 @@ void mark_rodata_ro(void) >size >> PAGE_SHIFT, PAGE_KERNEL_RX); > printk("Write protecting the kernel text: %luk\n", size >> 10); > } > + > + /* > + * global_flush_tlb() will be called after marking the data as readonly. > + */ > +} > + > +#ifdef CONFIG_DEBUG_RODATA > + > +void mark_rodata_ro(void) > +{ > + unsigned long start = PFN_ALIGN(_etext); > + unsigned long size = (unsigned long)__end_rodata - start; > + > +#ifdef CONFIG_DEBUG_ROTEXT > + mark_rwtext_ro(); > #endif > - start += size; > - size = (unsigned long)__end_rodata - start; > change_page_attr(virt_to_page(start), >size >> PAGE_SHIFT, PAGE_KERNEL_RO); > printk("Write protecting the kernel read-only data: %luk\n", > > _ > -- > Prasanna S.P. > Linux Technology Center > India Software Labs, IBM Bangalore > Email: [EMAIL PROTECTED] > Ph: 91-80-41776329 -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch 3/3] Text Edit Lock - kprobes i386
This suggestion looks more like a workaround to get rid of a bigger issue. If we do that, we have to use CONFIG_* exclusivity for either (ro-data protection) or (paravirt, kprobes, immediate values). One big advantage of my patch is that we can remove weird exclusivity cases involving paravirt and cpu hotplug, like this one: -#ifndef CONFIG_KPROBES -#ifdef CONFIG_HOTPLUG_CPU - /* It must still be possible to apply SMP alternatives. */ - if (num_possible_cpus() = 1) -#endif - { - change_page_attr(virt_to_page(start), -size PAGE_SHIFT, PAGE_KERNEL_RX); - printk(Write protecting the kernel text: %luk\n, size 10); - kernel_text_is_ro = 1; - } Mathieu * S. P. Prasanna ([EMAIL PROTECTED]) wrote: On Tue, Jul 03, 2007 at 12:38:22PM -0400, Mathieu Desnoyers wrote: Kprobes can use the text edit lock to insure mutual exclusion when edition the code and make sure the pages are writable. Linus suggested for splitting ro-data and ro-text; And allow ro-text only if kprobes is not configured. Please see the discussion thread, URL given below http://lkml.org/lkml/2007/6/20/436 This patch below allows to configure and mark the kernel text and kernel data as read-only separately. Also kernel text is configured read-only if kprobes is not configured. Thanks Prasanna This patch allows to configure and mark the kernel text and kernel data as read-only separately. Signed-off-by: Prasanna S P. [EMAIL PROTECTED] arch/i386/Kconfig.debug |8 arch/i386/mm/init.c | 22 -- 2 files changed, 24 insertions(+), 6 deletions(-) diff -puN arch/i386/Kconfig.debug~mark-kernel-text-data-ro-seperately-i386 arch/i386/Kconfig.debug --- linux-2.6.22-rc6/arch/i386/Kconfig.debug~mark-kernel-text-data-ro-seperately-i386 2007-07-04 13:45:24.0 +0530 +++ linux-2.6.22-rc6-prasanna/arch/i386/Kconfig.debug 2007-07-04 13:52:31.0 +0530 @@ -56,6 +56,14 @@ config DEBUG_RODATA portion of the kernel code won't be covered by a 2MB TLB anymore. If in doubt, say N. +config DEBUG_ROTEXT + bool Write protect kernel text + depends on DEBUG_RODATA !KPROBES + help + Mark the kernel text as write-protected in the pagetables. + Only allow this if kprobes is not configured. + If in doubt, say N. + config 4KSTACKS bool Use 4Kb for kernel stacks instead of 8Kb depends on DEBUG_KERNEL diff -puN arch/i386/mm/init.c~mark-kernel-text-data-ro-seperately-i386 arch/i386/mm/init.c --- linux-2.6.22-rc6/arch/i386/mm/init.c~mark-kernel-text-data-ro-seperately-i386 2007-07-04 13:45:24.0 +0530 +++ linux-2.6.22-rc6-prasanna/arch/i386/mm/init.c 2007-07-04 13:51:39.0 +0530 @@ -792,14 +792,11 @@ static int noinline do_test_wp_bit(void) return flag; } -#ifdef CONFIG_DEBUG_RODATA - -void mark_rodata_ro(void) +static inline void mark_rwtext_ro(void) { unsigned long start = PFN_ALIGN(_text); unsigned long size = PFN_ALIGN(_etext) - start; -#ifndef CONFIG_KPROBES #ifdef CONFIG_HOTPLUG_CPU /* It must still be possible to apply SMP alternatives. */ if (num_possible_cpus() = 1) @@ -809,9 +806,22 @@ void mark_rodata_ro(void) size PAGE_SHIFT, PAGE_KERNEL_RX); printk(Write protecting the kernel text: %luk\n, size 10); } + + /* + * global_flush_tlb() will be called after marking the data as readonly. + */ +} + +#ifdef CONFIG_DEBUG_RODATA + +void mark_rodata_ro(void) +{ + unsigned long start = PFN_ALIGN(_etext); + unsigned long size = (unsigned long)__end_rodata - start; + +#ifdef CONFIG_DEBUG_ROTEXT + mark_rwtext_ro(); #endif - start += size; - size = (unsigned long)__end_rodata - start; change_page_attr(virt_to_page(start), size PAGE_SHIFT, PAGE_KERNEL_RO); printk(Write protecting the kernel read-only data: %luk\n, _ -- Prasanna S.P. Linux Technology Center India Software Labs, IBM Bangalore Email: [EMAIL PROTECTED] Ph: 91-80-41776329 -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch 3/3] Text Edit Lock - kprobes i386
On Tue, Jul 03, 2007 at 12:38:22PM -0400, Mathieu Desnoyers wrote: > Kprobes can use the text edit lock to insure mutual exclusion when edition the > code and make sure the pages are writable. Linus suggested for splitting ro-data and ro-text; And allow ro-text only if kprobes is not configured. Please see the discussion thread, URL given below http://lkml.org/lkml/2007/6/20/436 This patch below allows to configure and mark the kernel text and kernel data as read-only separately. Also kernel text is configured read-only if kprobes is not configured. Thanks Prasanna This patch allows to configure and mark the kernel text and kernel data as read-only separately. Signed-off-by: Prasanna S P. <[EMAIL PROTECTED]> arch/i386/Kconfig.debug |8 arch/i386/mm/init.c | 22 -- 2 files changed, 24 insertions(+), 6 deletions(-) diff -puN arch/i386/Kconfig.debug~mark-kernel-text-data-ro-seperately-i386 arch/i386/Kconfig.debug --- linux-2.6.22-rc6/arch/i386/Kconfig.debug~mark-kernel-text-data-ro-seperately-i386 2007-07-04 13:45:24.0 +0530 +++ linux-2.6.22-rc6-prasanna/arch/i386/Kconfig.debug 2007-07-04 13:52:31.0 +0530 @@ -56,6 +56,14 @@ config DEBUG_RODATA portion of the kernel code won't be covered by a 2MB TLB anymore. If in doubt, say "N". +config DEBUG_ROTEXT + bool "Write protect kernel text" + depends on DEBUG_RODATA && !KPROBES + help + Mark the kernel text as write-protected in the pagetables. + Only allow this if kprobes is not configured. + If in doubt, say "N". + config 4KSTACKS bool "Use 4Kb for kernel stacks instead of 8Kb" depends on DEBUG_KERNEL diff -puN arch/i386/mm/init.c~mark-kernel-text-data-ro-seperately-i386 arch/i386/mm/init.c --- linux-2.6.22-rc6/arch/i386/mm/init.c~mark-kernel-text-data-ro-seperately-i386 2007-07-04 13:45:24.0 +0530 +++ linux-2.6.22-rc6-prasanna/arch/i386/mm/init.c 2007-07-04 13:51:39.0 +0530 @@ -792,14 +792,11 @@ static int noinline do_test_wp_bit(void) return flag; } -#ifdef CONFIG_DEBUG_RODATA - -void mark_rodata_ro(void) +static inline void mark_rwtext_ro(void) { unsigned long start = PFN_ALIGN(_text); unsigned long size = PFN_ALIGN(_etext) - start; -#ifndef CONFIG_KPROBES #ifdef CONFIG_HOTPLUG_CPU /* It must still be possible to apply SMP alternatives. */ if (num_possible_cpus() <= 1) @@ -809,9 +806,22 @@ void mark_rodata_ro(void) size >> PAGE_SHIFT, PAGE_KERNEL_RX); printk("Write protecting the kernel text: %luk\n", size >> 10); } + + /* +* global_flush_tlb() will be called after marking the data as readonly. +*/ +} + +#ifdef CONFIG_DEBUG_RODATA + +void mark_rodata_ro(void) +{ + unsigned long start = PFN_ALIGN(_etext); + unsigned long size = (unsigned long)__end_rodata - start; + +#ifdef CONFIG_DEBUG_ROTEXT + mark_rwtext_ro(); #endif - start += size; - size = (unsigned long)__end_rodata - start; change_page_attr(virt_to_page(start), size >> PAGE_SHIFT, PAGE_KERNEL_RO); printk("Write protecting the kernel read-only data: %luk\n", _ -- Prasanna S.P. Linux Technology Center India Software Labs, IBM Bangalore Email: [EMAIL PROTECTED] Ph: 91-80-41776329 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch 3/3] Text Edit Lock - kprobes i386
On Tue, Jul 03, 2007 at 12:38:22PM -0400, Mathieu Desnoyers wrote: Kprobes can use the text edit lock to insure mutual exclusion when edition the code and make sure the pages are writable. Linus suggested for splitting ro-data and ro-text; And allow ro-text only if kprobes is not configured. Please see the discussion thread, URL given below http://lkml.org/lkml/2007/6/20/436 This patch below allows to configure and mark the kernel text and kernel data as read-only separately. Also kernel text is configured read-only if kprobes is not configured. Thanks Prasanna This patch allows to configure and mark the kernel text and kernel data as read-only separately. Signed-off-by: Prasanna S P. [EMAIL PROTECTED] arch/i386/Kconfig.debug |8 arch/i386/mm/init.c | 22 -- 2 files changed, 24 insertions(+), 6 deletions(-) diff -puN arch/i386/Kconfig.debug~mark-kernel-text-data-ro-seperately-i386 arch/i386/Kconfig.debug --- linux-2.6.22-rc6/arch/i386/Kconfig.debug~mark-kernel-text-data-ro-seperately-i386 2007-07-04 13:45:24.0 +0530 +++ linux-2.6.22-rc6-prasanna/arch/i386/Kconfig.debug 2007-07-04 13:52:31.0 +0530 @@ -56,6 +56,14 @@ config DEBUG_RODATA portion of the kernel code won't be covered by a 2MB TLB anymore. If in doubt, say N. +config DEBUG_ROTEXT + bool Write protect kernel text + depends on DEBUG_RODATA !KPROBES + help + Mark the kernel text as write-protected in the pagetables. + Only allow this if kprobes is not configured. + If in doubt, say N. + config 4KSTACKS bool Use 4Kb for kernel stacks instead of 8Kb depends on DEBUG_KERNEL diff -puN arch/i386/mm/init.c~mark-kernel-text-data-ro-seperately-i386 arch/i386/mm/init.c --- linux-2.6.22-rc6/arch/i386/mm/init.c~mark-kernel-text-data-ro-seperately-i386 2007-07-04 13:45:24.0 +0530 +++ linux-2.6.22-rc6-prasanna/arch/i386/mm/init.c 2007-07-04 13:51:39.0 +0530 @@ -792,14 +792,11 @@ static int noinline do_test_wp_bit(void) return flag; } -#ifdef CONFIG_DEBUG_RODATA - -void mark_rodata_ro(void) +static inline void mark_rwtext_ro(void) { unsigned long start = PFN_ALIGN(_text); unsigned long size = PFN_ALIGN(_etext) - start; -#ifndef CONFIG_KPROBES #ifdef CONFIG_HOTPLUG_CPU /* It must still be possible to apply SMP alternatives. */ if (num_possible_cpus() = 1) @@ -809,9 +806,22 @@ void mark_rodata_ro(void) size PAGE_SHIFT, PAGE_KERNEL_RX); printk(Write protecting the kernel text: %luk\n, size 10); } + + /* +* global_flush_tlb() will be called after marking the data as readonly. +*/ +} + +#ifdef CONFIG_DEBUG_RODATA + +void mark_rodata_ro(void) +{ + unsigned long start = PFN_ALIGN(_etext); + unsigned long size = (unsigned long)__end_rodata - start; + +#ifdef CONFIG_DEBUG_ROTEXT + mark_rwtext_ro(); #endif - start += size; - size = (unsigned long)__end_rodata - start; change_page_attr(virt_to_page(start), size PAGE_SHIFT, PAGE_KERNEL_RO); printk(Write protecting the kernel read-only data: %luk\n, _ -- Prasanna S.P. Linux Technology Center India Software Labs, IBM Bangalore Email: [EMAIL PROTECTED] Ph: 91-80-41776329 - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch 3/3] Text Edit Lock - kprobes i386
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 <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] --- arch/i386/kernel/kprobes.c | 30 -- 1 file changed, 4 insertions(+), 26 deletions(-) Index: linux-2.6-lttng/arch/i386/kernel/kprobes.c === --- linux-2.6-lttng.orig/arch/i386/kernel/kprobes.c 2007-06-29 14:15:38.0 -0400 +++ linux-2.6-lttng/arch/i386/kernel/kprobes.c 2007-06-29 14:25:08.0 -0400 @@ -169,42 +169,20 @@ void __kprobes arch_arm_kprobe(struct kprobe *p) { - unsigned long addr = (unsigned long) p->addr; - int page_readonly = 0; - - if (kernel_readonly_text(addr)) { - page_readonly = 1; - change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RWX); - global_flush_tlb(); - } - + 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)); - - if (page_readonly) { - change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RX); - global_flush_tlb(); - } } void __kprobes arch_disarm_kprobe(struct kprobe *p) { - unsigned long addr = (unsigned long) p->addr; - int page_readonly = 0; - - if (kernel_readonly_text(addr)) { - page_readonly = 1; - change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RWX); - global_flush_tlb(); - } + 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)); - if (page_readonly) { - change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RX); - global_flush_tlb(); - } } void __kprobes arch_remove_kprobe(struct kprobe *p) -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch 3/3] Text Edit Lock - kprobes i386
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 [EMAIL PROTECTED] CC: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] --- arch/i386/kernel/kprobes.c | 30 -- 1 file changed, 4 insertions(+), 26 deletions(-) Index: linux-2.6-lttng/arch/i386/kernel/kprobes.c === --- linux-2.6-lttng.orig/arch/i386/kernel/kprobes.c 2007-06-29 14:15:38.0 -0400 +++ linux-2.6-lttng/arch/i386/kernel/kprobes.c 2007-06-29 14:25:08.0 -0400 @@ -169,42 +169,20 @@ void __kprobes arch_arm_kprobe(struct kprobe *p) { - unsigned long addr = (unsigned long) p-addr; - int page_readonly = 0; - - if (kernel_readonly_text(addr)) { - page_readonly = 1; - change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RWX); - global_flush_tlb(); - } - + 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)); - - if (page_readonly) { - change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RX); - global_flush_tlb(); - } } void __kprobes arch_disarm_kprobe(struct kprobe *p) { - unsigned long addr = (unsigned long) p-addr; - int page_readonly = 0; - - if (kernel_readonly_text(addr)) { - page_readonly = 1; - change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RWX); - global_flush_tlb(); - } + 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)); - if (page_readonly) { - change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RX); - global_flush_tlb(); - } } void __kprobes arch_remove_kprobe(struct kprobe *p) -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch 3/3] Text Edit Lock - kprobes i386
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 <[EMAIL PROTECTED]> --- 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.0 -0400 +++ linux-2.6-lttng/arch/i386/kernel/kprobes.c 2007-06-18 17:41:31.0 -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)); } -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch 3/3] Text Edit Lock - kprobes i386
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 [EMAIL PROTECTED] --- 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.0 -0400 +++ linux-2.6-lttng/arch/i386/kernel/kprobes.c 2007-06-18 17:41:31.0 -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)); } -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/