jprobe bugfix and cleanup
PATCH 1/6 jprobe bugfix and cleanup
This patch fixes a bug of jprobe and cleans up.
jprobe for x86-64 can cause kernel page fault when the jprobe_return() is called from incorrect function. Anyway, that path finally invokes BUG() macro, so this is not so serious.
- Use jprobe_saved_regs instead getting it from stack. (Especially on x86-64, it may get incorrect data, because pt_regs can not be get by using container_of(rsp))
- Change the type of stack pointer to unsigned long *.
Signed-off-by Masami Hiramatsu <[email protected]>
--- arch/x86/kernel/kprobes_32.c | 4 +--- arch/x86/kernel/kprobes_64.c | 4 +--- include/asm-x86/kprobes_32.h | 2 +- include/asm-x86/kprobes_64.h | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-)
arch/x86/kernel/kprobes_32.c +1 -3
@@ -742,9 +742,7 @@ int __kprobes longjmp_break_handler(struif ((addr > (u8 *) jprobe_return) && (addr < (u8 *) jprobe_return_end)) {if (®s->sp != kcb->jprobe_saved_esp) { -struct pt_regs *saved_regs = -container_of (kcb->jprobe_saved_esp, - struct pt_regs, sp); +struct pt_regs *saved_regs = &kcb->jprobe_saved_regs;printk ("current sp %p does not match saved sp %p\n" , ®s->sp, kcb->jprobe_saved_esp);printk ("Saved registers for jprobe %p\n" , jp);
arch/x86/kernel/kprobes_64.c +1 -3
@@ -732,9 +732,7 @@ int __kprobes longjmp_break_handler(struif ((addr > (u8 *) jprobe_return) && (addr < (u8 *) jprobe_return_end)) {if ((long *)regs->sp != kcb->jprobe_saved_rsp) { -struct pt_regs *saved_regs = -container_of (kcb->jprobe_saved_rsp, - struct pt_regs, sp); +struct pt_regs *saved_regs = &kcb->jprobe_saved_regs;printk ("current sp %p does not match saved sp %p\n" , (long *)regs->sp, kcb->jprobe_saved_rsp);printk ("Saved registers for jprobe %p\n" , jp);
include/asm-x86/kprobes_32.h +1 -1
@@ -73,7 +73,7 @@ struct kprobe_ctlblk {unsigned long kprobe_status;unsigned long kprobe_old_eflags;unsigned long kprobe_saved_eflags; -long *jprobe_saved_esp; +unsigned long *jprobe_saved_esp;struct pt_regs jprobe_saved_regs;kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE ];struct prev_kprobe prev_kprobe;
include/asm-x86/kprobes_64.h +1 -1
@@ -66,7 +66,7 @@ struct kprobe_ctlblk {unsigned long kprobe_status;unsigned long kprobe_old_rflags;unsigned long kprobe_saved_rflags; -long *jprobe_saved_rsp; +unsigned long *jprobe_saved_rsp;struct pt_regs jprobe_saved_regs;kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE ];struct prev_kprobe prev_kprobe;
Signature · 7 lines
Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: [email protected], [email protected]