From: Masami Hiramatsu <mhira...@kernel.org>

commit 004e8dce9c5595697951f7cd0e9f66b35c92265e upstream

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 <mhira...@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Cc: Juergen Gross <jgr...@suse.com>
Cc: x...@kernel.org
Cc: Boris Ostrovsky <boris.ostrov...@oracle.com>
Cc: Ingo Molnar <mi...@kernel.org>
Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Andrew Cooper <andrew.coop...@citrix.com>
Cc: Borislav Petkov <b...@alien8.de>
Cc: xen-devel@lists.xenproject.org
Cc: Randy Dunlap <rdun...@infradead.org>
Cc: Josh Poimboeuf <jpoim...@redhat.com>
Link: 
https://lkml.kernel.org/r/156777566048.25081.6296162369492175325.stgit@devnote2
Signed-off-by: Maximilian Heyne <mhe...@amazon.de>
Cc: sta...@vger.kernel.org # 5.4.x
---
 arch/x86/kernel/kprobes/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index c205d77d57da..3700dc94847c 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -358,6 +358,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;
-- 
2.32.0




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




Reply via email to