Commit c7b645f934e52a54af58142d91fb51f881f8ce26

Authored by Keshavamurthy Anil S
Committed by Linus Torvalds
1 parent a528e21c23

[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>

Showing 3 changed files with 23 additions and 3 deletions Side-by-side Diff

arch/ia64/kernel/kprobes.c
... ... @@ -34,6 +34,7 @@
34 34  
35 35 #include <asm/pgtable.h>
36 36 #include <asm/kdebug.h>
  37 +#include <asm/sections.h>
37 38  
38 39 extern void jprobe_inst_return(void);
39 40  
40 41  
41 42  
... ... @@ -263,13 +264,26 @@
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 274 static int valid_kprobe_addr(int template, int slot, unsigned long addr)
267 275 {
268 276 if ((slot > 2) || ((bundle_encoding[template][1] == L) && slot > 1)) {
269   - printk(KERN_WARNING "Attempting to insert unaligned kprobe at 0x%lx\n",
270   - addr);
  277 + printk(KERN_WARNING "Attempting to insert unaligned kprobe "
  278 + "at 0x%lx\n", addr);
271 279 return -EINVAL;
272 280 }
  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 + }
273 287  
274 288 if (slot == 1 && bundle_encoding[template][1] != L) {
275 289 printk(KERN_WARNING "Inserting kprobes on slot #1 "
arch/ia64/kernel/vmlinux.lds.S
... ... @@ -8,6 +8,11 @@
8 8 #define LOAD_OFFSET (KERNEL_START - KERNEL_TR_PAGE_SIZE)
9 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 16 OUTPUT_FORMAT("elf64-ia64-little")
12 17 OUTPUT_ARCH(ia64)
13 18 ENTRY(phys_start)
... ... @@ -39,7 +44,7 @@
39 44  
40 45 .text : AT(ADDR(.text) - LOAD_OFFSET)
41 46 {
42   - *(.text.ivt)
  47 + IVT_TEXT
43 48 *(.text)
44 49 SCHED_TEXT
45 50 LOCK_TEXT
include/asm-ia64/sections.h
... ... @@ -17,6 +17,7 @@
17 17 extern char __start_gate_fsyscall_patchlist[], __end_gate_fsyscall_patchlist[];
18 18 extern char __start_gate_brl_fsys_bubble_down_patchlist[], __end_gate_brl_fsys_bubble_down_patchlist[];
19 19 extern char __start_unwind[], __end_unwind[];
  20 +extern char __start_ivt_text[], __end_ivt_text[];
20 21  
21 22 #endif /* _ASM_IA64_SECTIONS_H */