[FIX] x86: do not install probes to call instruction
authorNikita Kalyazin <n.kalyazin@samsung.com>
Thu, 5 Dec 2013 10:13:18 +0000 (14:13 +0400)
committerNikita Kalyazin <n.kalyazin@samsung.com>
Thu, 5 Dec 2013 12:20:19 +0000 (16:20 +0400)
Workaround for __i686.get_pc_thunk.* related functions.
We cannot instrument not only such functions, but also functions that
call them.

Change-Id: Ifd431a12623a8ddb9beef952d3fed66c7701866c
Signed-off-by: Nikita Kalyazin <n.kalyazin@samsung.com>
uprobe/arch/asm-x86/swap_uprobes.c

index 2b9635b..0d09c77 100644 (file)
@@ -75,10 +75,16 @@ int arch_prepare_uprobe(struct uprobe *up)
        struct kprobe *p = up2kp(up);
        struct task_struct *task = up->task;
        u8 *tramp = up->atramp.tramp;
+       enum { call_relative_opcode = 0xe8 };
 
        if (!read_proc_vm_atomic(task, (unsigned long)p->addr,
                                 tramp, MAX_INSN_SIZE))
                panic("failed to read memory %p!\n", p->addr);
+       /* TODO: this is a workaround */
+       if (tramp[0] == call_relative_opcode) {
+               printk("cannot install probe: 1st instruction is call\n");
+               return -1;
+       }
 
        tramp[UPROBES_TRAMP_RET_BREAK_IDX] = BREAKPOINT_INSTRUCTION;