OSDN Git Service

x86: kprobes: Prohibit probing on instruction which has emulate prefix
authorMasami Hiramatsu <mhiramat@kernel.org>
Fri, 6 Sep 2019 13:14:20 +0000 (22:14 +0900)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 17 Oct 2019 19:31:57 +0000 (21:31 +0200)
Prohibit probing on instruction which has XEN_EMULATE_PREFIX
or KVM's emulate prefix. Since that prefix is a marker for Xen
and KVM, if we modify the marker by kprobe's int3, that doesn't
work as expected.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: x86@kernel.org
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: xen-devel@lists.xenproject.org
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/156777566048.25081.6296162369492175325.stgit@devnote2
arch/x86/kernel/kprobes/core.c

index 43fc13c..4f13af7 100644 (file)
@@ -351,6 +351,10 @@ int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn)
        kernel_insn_init(insn, dest, MAX_INSN_SIZE);
        insn_get_length(insn);
 
+       /* We can not probe force emulate prefixed instruction */
+       if (insn_has_emulate_prefix(insn))
+               return 0;
+
        /* Another subsystem puts a breakpoint, failed to recover */
        if (insn->opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
                return 0;