From: Peter Zijlstra <peterz@infradead.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Dave Hansen <dave.hansen@intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>, yu-cheng.yu@intel.com
Subject: [RFC][PATCH] objtool: WARN about ENDBR instructions
Date: Wed, 10 Feb 2021 09:39:53 +0100 [thread overview]
Message-ID: <YCOb2byLJhLOjhrL@hirez.programming.kicks-ass.net> (raw)
Given all the ENDBR fun we recently had, do we want the below? Until
someone comes and fixes up kprobes/ftrace/livepatch etc.. having them is
a giant pain and we'd better warn about it.
---
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 931cef78b857..e708731b10cd 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -91,7 +91,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
{
struct insn insn;
int x86_64, sign;
- unsigned char op1, op2, rex = 0, rex_b = 0, rex_r = 0, rex_w = 0,
+ unsigned char op1, op2, pfx = 0, rex = 0, rex_b = 0, rex_r = 0, rex_w = 0,
rex_x = 0, modrm = 0, modrm_mod = 0, modrm_rm = 0,
modrm_reg = 0, sib = 0;
struct stack_op *op = NULL;
@@ -118,6 +118,9 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
op1 = insn.opcode.bytes[0];
op2 = insn.opcode.bytes[1];
+ if (insn.prefixes.nbytes)
+ pfx = insn.prefixes.bytes[0];
+
if (insn.rex_prefix.nbytes) {
rex = insn.rex_prefix.bytes[0];
rex_w = X86_REX_W(rex) >> 3;
@@ -444,6 +447,11 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
/* nopl/nopw */
*type = INSN_NOP;
+ } else if (op2 == 0x1e && pfx == 0xf3 && (modrm == 0xfa || modrm == 0xfb)) {
+
+ /* endbr32/endbr64 */
+ WARN("endbr32/64 instruction at %s:0x%lx", sec->name, offset);
+
} else if (op2 == 0xa0 || op2 == 0xa8) {
/* push fs/gs */
next reply other threads:[~2021-02-10 8:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-10 8:39 Peter Zijlstra [this message]
2021-02-10 16:09 ` [RFC][PATCH] objtool: WARN about ENDBR instructions Josh Poimboeuf
2021-02-10 17:01 ` Peter Zijlstra
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=YCOb2byLJhLOjhrL@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=dave.hansen@intel.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
--cc=yu-cheng.yu@intel.com \
/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