From: Maximilian Heyne <mheyne@amazon.de>
To: unlisted-recipients:; (no To-header on input)
Cc: "Masami Hiramatsu" <mhiramat@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Juergen Gross" <jgross@suse.com>,
x86@kernel.org, "Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
"Ingo Molnar" <mingo@kernel.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Borislav Petkov" <bp@alien8.de>,
xen-devel@lists.xenproject.org,
"Randy Dunlap" <rdunlap@infradead.org>,
"Josh Poimboeuf" <jpoimboe@redhat.com>,
"Maximilian Heyne" <mheyne@amazon.de>,
stable@vger.kernel.org, "Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Sean Christopherson" <sean.j.christopherson@intel.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
"Wanpeng Li" <wanpengli@tencent.com>,
"Jim Mattson" <jmattson@google.com>,
"Joerg Roedel" <joro@8bytes.org>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@redhat.com>,
"Namhyung Kim" <namhyung@kernel.org>,
"Sasha Levin" <sashal@kernel.org>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: [PATCH 4/4] x86: kprobes: Prohibit probing on instruction which has emulate prefix
Date: Tue, 10 May 2022 13:30:33 +0000 [thread overview]
Message-ID: <20220510133036.46767-5-mheyne@amazon.de> (raw)
In-Reply-To: <20220510133036.46767-1-mheyne@amazon.de>
From: Masami Hiramatsu <mhiramat@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 <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
Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
Cc: stable@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
next prev parent reply other threads:[~2022-05-10 14:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 13:30 [PATCH 0/4] x86: decode Xen/KVM emulate prefixes Maximilian Heyne
2022-05-10 13:30 ` [PATCH 1/4] x86/asm: Allow to pass macros to __ASM_FORM() Maximilian Heyne
2022-05-10 13:30 ` [PATCH 2/4] x86: xen: kvm: Gather the definition of emulate prefixes Maximilian Heyne
2022-05-10 13:30 ` [PATCH 3/4] x86: xen: insn: Decode Xen and KVM emulate-prefix signature Maximilian Heyne
2022-05-10 13:30 ` Maximilian Heyne [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-05-12 13:56 [PATCH 0/4] x86: decode Xen/KVM emulate prefixes Maximilian Heyne
2022-05-12 13:56 ` [PATCH 4/4] x86: kprobes: Prohibit probing on instruction which has emulate prefix Maximilian Heyne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220510133036.46767-5-mheyne@amazon.de \
--to=mheyne@amazon.de \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=jmattson@google.com \
--cc=jolsa@redhat.com \
--cc=joro@8bytes.org \
--cc=jpoimboe@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=rkrcmar@redhat.com \
--cc=sashal@kernel.org \
--cc=sean.j.christopherson@intel.com \
--cc=sstabellini@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox