x86: Remove arbitrary instruction size limit in instruction decoder
[linux-block.git] / arch / x86 / kernel / kprobes / opt.c
index f1314d0bcf0ab64c7ff65099b9b3dd835f192c72..7c523bbf3dc8fc3f95acf0a374e9f6f1164c3f47 100644 (file)
@@ -251,13 +251,15 @@ static int can_optimize(unsigned long paddr)
        /* Decode instructions */
        addr = paddr - offset;
        while (addr < paddr - offset + size) { /* Decode until function end */
+               unsigned long recovered_insn;
                if (search_exception_tables(addr))
                        /*
                         * Since some fixup code will jumps into this function,
                         * we can't optimize kprobe in this function.
                         */
                        return 0;
-               kernel_insn_init(&insn, (void *)recover_probed_instruction(buf, addr));
+               recovered_insn = recover_probed_instruction(buf, addr);
+               kernel_insn_init(&insn, (void *)recovered_insn, MAX_INSN_SIZE);
                insn_get_length(&insn);
                /* Another subsystem puts a breakpoint */
                if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)