* [patch][ia64]Refuse kprobe on ivt code
@ 2005-06-24 0:28 Keshavamurthy Anil S
2005-06-24 1:38 ` David Mosberger
0 siblings, 1 reply; 6+ messages in thread
From: Keshavamurthy Anil S @ 2005-06-24 0:28 UTC (permalink / raw)
To: akpm; +Cc: Linux Kernel, Linux IA64
Subject: Refuse kprobe insert on IVT code
Not safe to insert kprobes on IVT code.
This patch checks to see if the address on which Kprobes is being
inserted is in ivt code and if it is in ivt code then
refuse to register kprobe.
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
======================= arch/ia64/kernel/kprobes.c | 13 +++++++++++++
1 files changed, 13 insertions(+)
Index: linux-2.6.12-mm1/arch/ia64/kernel/kprobes.c
=================================--- linux-2.6.12-mm1.orig/arch/ia64/kernel/kprobes.c
+++ linux-2.6.12-mm1/arch/ia64/kernel/kprobes.c
@@ -263,6 +263,13 @@ static inline void get_kprobe_inst(bundl
}
}
+/* Returns non-zero if the PC is in the Interrupt Vector Table */
+static inline int in_ivt_code(unsigned long pc)
+{
+ extern char ia64_ivt[];
+ return (pc >= (u_long)ia64_ivt && pc < (u_long)ia64_ivt+32768);
+}
+
static int valid_kprobe_addr(int template, int slot, unsigned long addr)
{
if ((slot > 2) || ((bundle_encoding[template][1] = L) && slot > 1)) {
@@ -271,6 +278,12 @@ static int valid_kprobe_addr(int templat
return -EINVAL;
}
+ if (in_ivt_code(addr)) {
+ printk(KERN_WARNING "Kprobes can't be inserted inside "
+ "IVT code at 0x%lx\n", addr);
+ return -EINVAL;
+ }
+
if (slot = 1) {
printk(KERN_WARNING "Inserting kprobes on slot #1 "
"is not supported\n");
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch][ia64]Refuse kprobe on ivt code 2005-06-24 0:28 [patch][ia64]Refuse kprobe on ivt code Keshavamurthy Anil S @ 2005-06-24 1:38 ` David Mosberger 2005-06-24 18:45 ` Keshavamurthy Anil S 0 siblings, 1 reply; 6+ messages in thread From: David Mosberger @ 2005-06-24 1:38 UTC (permalink / raw) To: Keshavamurthy Anil S; +Cc: akpm, Linux Kernel, Linux IA64 Please do the checking based on the .text.ivt section instead (and add the necessary labels to vmlinux.S and asm-ia64/sections.h). Thanks, --david >>>>> On Thu, 23 Jun 2005 17:28:33 -0700, Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> said: Anil> Subject: Refuse kprobe insert on IVT code Anil> Not safe to insert kprobes on IVT code. Anil> This patch checks to see if the address on which Kprobes is Anil> being inserted is in ivt code and if it is in ivt code then Anil> refuse to register kprobe. Anil> Signed-off-by: Anil S Keshavamurthy Anil> <anil.s.keshavamurthy@intel.com> Anil> ======================= Anil> arch/ia64/kernel/kprobes.c | 13 +++++++++++++ 1 files changed, Anil> 13 insertions(+) Anil> Index: linux-2.6.12-mm1/arch/ia64/kernel/kprobes.c Anil> ================================= Anil> --- linux-2.6.12-mm1.orig/arch/ia64/kernel/kprobes.c +++ Anil> linux-2.6.12-mm1/arch/ia64/kernel/kprobes.c @@ -263,6 +263,13 Anil> @@ static inline void get_kprobe_inst(bundl } } Anil> +/* Returns non-zero if the PC is in the Interrupt Vector Anil> Table */ +static inline int in_ivt_code(unsigned long pc) +{ + Anil> extern char ia64_ivt[]; + return (pc >= (u_long)ia64_ivt && pc Anil> < (u_long)ia64_ivt+32768); +} + static int Anil> valid_kprobe_addr(int template, int slot, unsigned long addr) Anil> { if ((slot > 2) || ((bundle_encoding[template][1] = L) && Anil> slot > 1)) { @@ -271,6 +278,12 @@ static int Anil> valid_kprobe_addr(int templat return -EINVAL; } Anil> + if (in_ivt_code(addr)) { + printk(KERN_WARNING "Kprobes Anil> can't be inserted inside " + "IVT code at 0x%lx\n", addr); + Anil> return -EINVAL; + } + if (slot = 1) { printk(KERN_WARNING Anil> "Inserting kprobes on slot #1 " "is not supported\n"); - To Anil> unsubscribe from this list: send the line "unsubscribe Anil> linux-ia64" in the body of a message to Anil> majordomo@vger.kernel.org More majordomo info at Anil> http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch][ia64]Refuse kprobe on ivt code 2005-06-24 1:38 ` David Mosberger @ 2005-06-24 18:45 ` Keshavamurthy Anil S 2005-06-24 19:10 ` David Mosberger 0 siblings, 1 reply; 6+ messages in thread From: Keshavamurthy Anil S @ 2005-06-24 18:45 UTC (permalink / raw) To: davidm; +Cc: Keshavamurthy Anil S, akpm, Linux Kernel, Linux IA64 On Thu, Jun 23, 2005 at 06:38:33PM -0700, David Mosberger wrote: > Please do the checking based on the .text.ivt section instead (and add > the necessary labels to vmlinux.S and asm-ia64/sections.h). Subject: Refuse kprobe insert on IVT code Not safe to insert kprobes on IVT code. This patch checks to see if the address on which Kprobes is being inserted is in ivt code and if it is in ivt code then refuse to register kprobe. Take 1: This patch is based on review comments from David Mosberger, now checking based on .text.ivt Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> ======================= arch/ia64/kernel/kprobes.c | 14 ++++++++++++++ arch/ia64/kernel/vmlinux.lds.S | 7 ++++++- include/asm-ia64/sections.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) Index: linux-2.6.12-mm1/arch/ia64/kernel/kprobes.c =================================--- linux-2.6.12-mm1.orig/arch/ia64/kernel/kprobes.c +++ linux-2.6.12-mm1/arch/ia64/kernel/kprobes.c @@ -263,6 +263,14 @@ static inline void get_kprobe_inst(bundl } } +/* Returns non-zero if the addr is in the Interrupt Vector Table */ +static inline int in_ivt_functions(unsigned long addr) +{ + extern char __start_ivt_text[], __end_ivt_text[]; + return (addr >= (unsigned long)__start_ivt_text + && addr < (unsigned long)__end_ivt_text); +} + static int valid_kprobe_addr(int template, int slot, unsigned long addr) { if ((slot > 2) || ((bundle_encoding[template][1] = L) && slot > 1)) { @@ -271,6 +279,12 @@ static int valid_kprobe_addr(int templat return -EINVAL; } + if (in_ivt_functions(addr)) { + printk(KERN_WARNING "Kprobes can't be inserted inside " + "IVT code at 0x%lx\n", addr); + return -EINVAL; + } + if (slot = 1) { printk(KERN_WARNING "Inserting kprobes on slot #1 " "is not supported\n"); Index: linux-2.6.12-mm1/arch/ia64/kernel/vmlinux.lds.S =================================--- linux-2.6.12-mm1.orig/arch/ia64/kernel/vmlinux.lds.S +++ linux-2.6.12-mm1/arch/ia64/kernel/vmlinux.lds.S @@ -8,6 +8,11 @@ #define LOAD_OFFSET (KERNEL_START - KERNEL_TR_PAGE_SIZE) #include <asm-generic/vmlinux.lds.h> +#define IVT_TEXT \ + VMLINUX_SYMBOL(__start_ivt_text) = .; \ + *(.text.ivt) \ + VMLINUX_SYMBOL(__end_ivt_text) = .; + OUTPUT_FORMAT("elf64-ia64-little") OUTPUT_ARCH(ia64) ENTRY(phys_start) @@ -39,7 +44,7 @@ SECTIONS .text : AT(ADDR(.text) - LOAD_OFFSET) { - *(.text.ivt) + IVT_TEXT *(.text) SCHED_TEXT LOCK_TEXT Index: linux-2.6.12-mm1/include/asm-ia64/sections.h =================================--- linux-2.6.12-mm1.orig/include/asm-ia64/sections.h +++ linux-2.6.12-mm1/include/asm-ia64/sections.h @@ -17,6 +17,7 @@ extern char __start_gate_vtop_patchlist[ extern char __start_gate_fsyscall_patchlist[], __end_gate_fsyscall_patchlist[]; extern char __start_gate_brl_fsys_bubble_down_patchlist[], __end_gate_brl_fsys_bubble_down_patchlist[]; extern char __start_unwind[], __end_unwind[]; +extern char __start_ivt_text[], __end_ivt_text[]; #endif /* _ASM_IA64_SECTIONS_H */ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch][ia64]Refuse kprobe on ivt code 2005-06-24 18:45 ` Keshavamurthy Anil S @ 2005-06-24 19:10 ` David Mosberger 2005-06-24 19:23 ` [patch][ia64]Refuse kprobe on ivt code- take 2 Keshavamurthy Anil S 0 siblings, 1 reply; 6+ messages in thread From: David Mosberger @ 2005-06-24 19:10 UTC (permalink / raw) To: Keshavamurthy Anil S; +Cc: davidm, akpm, Linux Kernel, Linux IA64 >>>>> On Fri, 24 Jun 2005 11:45:46 -0700, Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> said: Anil> On Thu, Jun 23, 2005 at 06:38:33PM -0700, David Mosberger wrote: >> Please do the checking based on the .text.ivt section instead (and add >> the necessary labels to vmlinux.S and asm-ia64/sections.h). Anil> Subject: Refuse kprobe insert on IVT code Anil> Not safe to insert kprobes on IVT code. Anil> This patch checks to see if the address on which Kprobes is being Anil> inserted is in ivt code and if it is in ivt code then Anil> refuse to register kprobe. Anil> Take 1: This patch is based on review comments from David Mosberger, Anil> now checking based on .text.ivt Anil> Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Looks fine, except: Anil> +/* Returns non-zero if the addr is in the Interrupt Vector Table */ Anil> +static inline int in_ivt_functions(unsigned long addr) Anil> +{ Anil> + extern char __start_ivt_text[], __end_ivt_text[]; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Anil> + return (addr >= (unsigned long)__start_ivt_text Anil> + && addr < (unsigned long)__end_ivt_text); Anil> +} Surely you meant to use the declaration from sections.h instead? Thanks, --david ^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch][ia64]Refuse kprobe on ivt code- take 2 2005-06-24 19:10 ` David Mosberger @ 2005-06-24 19:23 ` Keshavamurthy Anil S 2005-06-24 20:37 ` David Mosberger 0 siblings, 1 reply; 6+ messages in thread From: Keshavamurthy Anil S @ 2005-06-24 19:23 UTC (permalink / raw) To: davidm; +Cc: Keshavamurthy Anil S, akpm, Linux Kernel, Linux IA64 On Fri, Jun 24, 2005 at 12:10:38PM -0700, David Mosberger wrote: > >>>>> On Fri, 24 Jun 2005 11:45:46 -0700, Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> said: > Surely you meant to use the declaration from sections.h instead? Take 1: This patch is based on review comments from David Mosberger, now checking based on .text.ivt Take 2: now including sections.h :-) Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> ======================= arch/ia64/kernel/kprobes.c | 14 ++++++++++++++ arch/ia64/kernel/vmlinux.lds.S | 7 ++++++- include/asm-ia64/sections.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) Index: linux-2.6.12-mm1/arch/ia64/kernel/kprobes.c =================================--- linux-2.6.12-mm1.orig/arch/ia64/kernel/kprobes.c +++ linux-2.6.12-mm1/arch/ia64/kernel/kprobes.c @@ -34,6 +34,7 @@ #include <asm/pgtable.h> #include <asm/kdebug.h> +#include <asm/sections.h> extern void jprobe_inst_return(void); @@ -263,6 +264,13 @@ static inline void get_kprobe_inst(bundl } } +/* Returns non-zero if the addr is in the Interrupt Vector Table */ +static inline int in_ivt_functions(unsigned long addr) +{ + return (addr >= (unsigned long)__start_ivt_text + && addr < (unsigned long)__end_ivt_text); +} + static int valid_kprobe_addr(int template, int slot, unsigned long addr) { if ((slot > 2) || ((bundle_encoding[template][1] = L) && slot > 1)) { @@ -271,6 +279,12 @@ static int valid_kprobe_addr(int templat return -EINVAL; } + if (in_ivt_functions(addr)) { + printk(KERN_WARNING "Kprobes can't be inserted inside " + "IVT functions at 0x%lx\n", addr); + return -EINVAL; + } + if (slot = 1) { printk(KERN_WARNING "Inserting kprobes on slot #1 " "is not supported\n"); Index: linux-2.6.12-mm1/arch/ia64/kernel/vmlinux.lds.S =================================--- linux-2.6.12-mm1.orig/arch/ia64/kernel/vmlinux.lds.S +++ linux-2.6.12-mm1/arch/ia64/kernel/vmlinux.lds.S @@ -8,6 +8,11 @@ #define LOAD_OFFSET (KERNEL_START - KERNEL_TR_PAGE_SIZE) #include <asm-generic/vmlinux.lds.h> +#define IVT_TEXT \ + VMLINUX_SYMBOL(__start_ivt_text) = .; \ + *(.text.ivt) \ + VMLINUX_SYMBOL(__end_ivt_text) = .; + OUTPUT_FORMAT("elf64-ia64-little") OUTPUT_ARCH(ia64) ENTRY(phys_start) @@ -39,7 +44,7 @@ SECTIONS .text : AT(ADDR(.text) - LOAD_OFFSET) { - *(.text.ivt) + IVT_TEXT *(.text) SCHED_TEXT LOCK_TEXT Index: linux-2.6.12-mm1/include/asm-ia64/sections.h =================================--- linux-2.6.12-mm1.orig/include/asm-ia64/sections.h +++ linux-2.6.12-mm1/include/asm-ia64/sections.h @@ -17,6 +17,7 @@ extern char __start_gate_vtop_patchlist[ extern char __start_gate_fsyscall_patchlist[], __end_gate_fsyscall_patchlist[]; extern char __start_gate_brl_fsys_bubble_down_patchlist[], __end_gate_brl_fsys_bubble_down_patchlist[]; extern char __start_unwind[], __end_unwind[]; +extern char __start_ivt_text[], __end_ivt_text[]; #endif /* _ASM_IA64_SECTIONS_H */ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch][ia64]Refuse kprobe on ivt code- take 2 2005-06-24 19:23 ` [patch][ia64]Refuse kprobe on ivt code- take 2 Keshavamurthy Anil S @ 2005-06-24 20:37 ` David Mosberger 0 siblings, 0 replies; 6+ messages in thread From: David Mosberger @ 2005-06-24 20:37 UTC (permalink / raw) To: Keshavamurthy Anil S; +Cc: davidm, akpm, Linux Kernel, Linux IA64 >>>>> On Fri, 24 Jun 2005 12:23:33 -0700, Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> said: Anil> On Fri, Jun 24, 2005 at 12:10:38PM -0700, David Mosberger wrote: >> >>>>> On Fri, 24 Jun 2005 11:45:46 -0700, Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> said: >> Surely you meant to use the declaration from sections.h instead? Anil> Take 1: This patch is based on review comments from David Mosberger, Anil> now checking based on .text.ivt Anil> Take 2: now including sections.h :-) Looks fine to me. Thanks, --david ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-06-24 20:37 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-06-24 0:28 [patch][ia64]Refuse kprobe on ivt code Keshavamurthy Anil S 2005-06-24 1:38 ` David Mosberger 2005-06-24 18:45 ` Keshavamurthy Anil S 2005-06-24 19:10 ` David Mosberger 2005-06-24 19:23 ` [patch][ia64]Refuse kprobe on ivt code- take 2 Keshavamurthy Anil S 2005-06-24 20:37 ` David Mosberger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox