diff options
author | Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> | 2005-06-27 18:17:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-27 18:23:54 -0400 |
commit | c7b645f934e52a54af58142d91fb51f881f8ce26 (patch) | |
tree | 97ef8305edf17c07b7e0cc63453548e99e84b8fd | |
parent | a528e21c235862cc1ae50e7809eb9116dc40ea0c (diff) |
[PATCH] kprobes/ia64: refuse kprobe 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>
Acked-by: David Mosberger <davidm@napali.hpl.hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/ia64/kernel/kprobes.c | 18 | ||||
-rw-r--r-- | arch/ia64/kernel/vmlinux.lds.S | 7 | ||||
-rw-r--r-- | include/asm-ia64/sections.h | 1 |
3 files changed, 23 insertions, 3 deletions
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c index ec2ceade12b0..3aa3167edbec 100644 --- a/arch/ia64/kernel/kprobes.c +++ b/arch/ia64/kernel/kprobes.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | #include <asm/pgtable.h> | 35 | #include <asm/pgtable.h> |
36 | #include <asm/kdebug.h> | 36 | #include <asm/kdebug.h> |
37 | #include <asm/sections.h> | ||
37 | 38 | ||
38 | extern void jprobe_inst_return(void); | 39 | extern void jprobe_inst_return(void); |
39 | 40 | ||
@@ -263,14 +264,27 @@ static inline void get_kprobe_inst(bundle_t *bundle, uint slot, | |||
263 | } | 264 | } |
264 | } | 265 | } |
265 | 266 | ||
267 | /* Returns non-zero if the addr is in the Interrupt Vector Table */ | ||
268 | static inline int in_ivt_functions(unsigned long addr) | ||
269 | { | ||
270 | return (addr >= (unsigned long)__start_ivt_text | ||
271 | && addr < (unsigned long)__end_ivt_text); | ||
272 | } | ||
273 | |||
266 | static int valid_kprobe_addr(int template, int slot, unsigned long addr) | 274 | static int valid_kprobe_addr(int template, int slot, unsigned long addr) |
267 | { | 275 | { |
268 | if ((slot > 2) || ((bundle_encoding[template][1] == L) && slot > 1)) { | 276 | if ((slot > 2) || ((bundle_encoding[template][1] == L) && slot > 1)) { |
269 | printk(KERN_WARNING "Attempting to insert unaligned kprobe at 0x%lx\n", | 277 | printk(KERN_WARNING "Attempting to insert unaligned kprobe " |
270 | addr); | 278 | "at 0x%lx\n", addr); |
271 | return -EINVAL; | 279 | return -EINVAL; |
272 | } | 280 | } |
273 | 281 | ||
282 | if (in_ivt_functions(addr)) { | ||
283 | printk(KERN_WARNING "Kprobes can't be inserted inside " | ||
284 | "IVT functions at 0x%lx\n", addr); | ||
285 | return -EINVAL; | ||
286 | } | ||
287 | |||
274 | if (slot == 1 && bundle_encoding[template][1] != L) { | 288 | if (slot == 1 && bundle_encoding[template][1] != L) { |
275 | printk(KERN_WARNING "Inserting kprobes on slot #1 " | 289 | printk(KERN_WARNING "Inserting kprobes on slot #1 " |
276 | "is not supported\n"); | 290 | "is not supported\n"); |
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S index b9f0db4c1b04..a676e79e0681 100644 --- a/arch/ia64/kernel/vmlinux.lds.S +++ b/arch/ia64/kernel/vmlinux.lds.S | |||
@@ -8,6 +8,11 @@ | |||
8 | #define LOAD_OFFSET (KERNEL_START - KERNEL_TR_PAGE_SIZE) | 8 | #define LOAD_OFFSET (KERNEL_START - KERNEL_TR_PAGE_SIZE) |
9 | #include <asm-generic/vmlinux.lds.h> | 9 | #include <asm-generic/vmlinux.lds.h> |
10 | 10 | ||
11 | #define IVT_TEXT \ | ||
12 | VMLINUX_SYMBOL(__start_ivt_text) = .; \ | ||
13 | *(.text.ivt) \ | ||
14 | VMLINUX_SYMBOL(__end_ivt_text) = .; | ||
15 | |||
11 | OUTPUT_FORMAT("elf64-ia64-little") | 16 | OUTPUT_FORMAT("elf64-ia64-little") |
12 | OUTPUT_ARCH(ia64) | 17 | OUTPUT_ARCH(ia64) |
13 | ENTRY(phys_start) | 18 | ENTRY(phys_start) |
@@ -39,7 +44,7 @@ SECTIONS | |||
39 | 44 | ||
40 | .text : AT(ADDR(.text) - LOAD_OFFSET) | 45 | .text : AT(ADDR(.text) - LOAD_OFFSET) |
41 | { | 46 | { |
42 | *(.text.ivt) | 47 | IVT_TEXT |
43 | *(.text) | 48 | *(.text) |
44 | SCHED_TEXT | 49 | SCHED_TEXT |
45 | LOCK_TEXT | 50 | LOCK_TEXT |
diff --git a/include/asm-ia64/sections.h b/include/asm-ia64/sections.h index 8e3dbde1b429..e9eb7f62d32b 100644 --- a/include/asm-ia64/sections.h +++ b/include/asm-ia64/sections.h | |||
@@ -17,6 +17,7 @@ extern char __start_gate_vtop_patchlist[], __end_gate_vtop_patchlist[]; | |||
17 | extern char __start_gate_fsyscall_patchlist[], __end_gate_fsyscall_patchlist[]; | 17 | extern char __start_gate_fsyscall_patchlist[], __end_gate_fsyscall_patchlist[]; |
18 | extern char __start_gate_brl_fsys_bubble_down_patchlist[], __end_gate_brl_fsys_bubble_down_patchlist[]; | 18 | extern char __start_gate_brl_fsys_bubble_down_patchlist[], __end_gate_brl_fsys_bubble_down_patchlist[]; |
19 | extern char __start_unwind[], __end_unwind[]; | 19 | extern char __start_unwind[], __end_unwind[]; |
20 | extern char __start_ivt_text[], __end_ivt_text[]; | ||
20 | 21 | ||
21 | #endif /* _ASM_IA64_SECTIONS_H */ | 22 | #endif /* _ASM_IA64_SECTIONS_H */ |
22 | 23 | ||