uprobes/x86: Emulate relative conditional "near" jmp's
authorOleg Nesterov <oleg@redhat.com>
Mon, 7 Apr 2014 14:22:58 +0000 (16:22 +0200)
committerOleg Nesterov <oleg@redhat.com>
Thu, 17 Apr 2014 19:58:25 +0000 (21:58 +0200)
Change branch_setup_xol_ops() to simply use opc1 = OPCODE2(insn) - 0x10
if OPCODE1() == 0x0f; this matches the "short" jmp which checks the same
condition.

Thanks to lib/insn.c, it does the rest correctly. branch->ilen/offs are
correct no matter if this jmp is "near" or "short".

Reported-by: Jonathan Lebon <jlebon@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Jim Keniston <jkenisto@us.ibm.com>
arch/x86/kernel/uprobes.c

index 0460d04f0acc98366badf3a6d4b088a809786621..ace22916ade3ce60859ead56db7f2c8f08ff9760 100644 (file)
@@ -599,6 +599,14 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
                branch_clear_offset(auprobe, insn);
                break;
 
+       case 0x0f:
+               if (insn->opcode.nbytes != 2)
+                       return -ENOSYS;
+               /*
+                * If it is a "near" conditional jmp, OPCODE2() - 0x10 matches
+                * OPCODE1() of the "short" jmp which checks the same condition.
+                */
+               opc1 = OPCODE2(insn) - 0x10;
        default:
                if (!is_cond_jmp_opcode(opc1))
                        return -ENOSYS;