From: Peter Zijlstra <peterz@infradead.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
alyssa.milburn@intel.com, scott.d.constable@intel.com,
joao@overdrivepizza.com, andrew.cooper3@citrix.com,
jpoimboe@kernel.org, jose.marchesi@oracle.com,
hjl.tools@gmail.com, ndesaulniers@google.com,
samitolvanen@google.com, nathan@kernel.org, ojeda@kernel.org,
kees@kernel.org, alexei.starovoitov@gmail.com,
mhiramat@kernel.org, jmill@asu.edu
Subject: [PATCH v4 03/10] x86/traps: Decode 0xEA #UD
Date: Mon, 24 Feb 2025 13:37:06 +0100 [thread overview]
Message-ID: <20250224124200.166774696@infradead.org> (raw)
In-Reply-To: 20250224123703.843199044@infradead.org
FineIBT will start using 0xEA as #UD
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/include/asm/bug.h | 1 +
arch/x86/kernel/traps.c | 20 +++++++++++++++++---
2 files changed, 18 insertions(+), 3 deletions(-)
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -25,6 +25,7 @@
#define BUG_UD2 0xfffe
#define BUG_UD1 0xfffd
#define BUG_UD1_UBSAN 0xfffc
+#define BUG_EA 0xffea
#ifdef CONFIG_GENERIC_BUG
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -96,6 +96,7 @@ __always_inline int is_valid_bugaddr(uns
* Check for UD1 or UD2, accounting for Address Size Override Prefixes.
* If it's a UD1, further decode to determine its use:
*
+ * FineIBT: ea (bad)
* UBSan{0}: 67 0f b9 00 ud1 (%eax),%eax
* UBSan{10}: 67 0f b9 40 10 ud1 0x10(%eax),%eax
* static_call: 0f b9 cc ud1 %esp,%ecx
@@ -113,6 +114,10 @@ __always_inline int decode_bug(unsigned
v = *(u8 *)(addr++);
if (v == INSN_ASOP)
v = *(u8 *)(addr++);
+ if (v == 0xea) {
+ *len = addr - start;
+ return BUG_EA;
+ }
if (v != OPCODE_ESCAPE)
return BUG_NONE;
@@ -309,10 +314,16 @@ static noinstr bool handle_bug(struct pt
switch (ud_type) {
case BUG_UD2:
- if (report_bug(regs->ip, regs) == BUG_TRAP_TYPE_WARN ||
- handle_cfi_failure(regs) == BUG_TRAP_TYPE_WARN) {
- regs->ip += ud_len;
+ if (report_bug(regs->ip, regs) == BUG_TRAP_TYPE_WARN) {
+ handled = true;
+ break;
+ }
+ fallthrough;
+
+ case BUG_EA:
+ if (handle_cfi_failure(regs) == BUG_TRAP_TYPE_WARN) {
handled = true;
+ break;
}
break;
@@ -328,6 +339,9 @@ static noinstr bool handle_bug(struct pt
break;
}
+ if (handled)
+ regs->ip += ud_len;
+
if (regs->flags & X86_EFLAGS_IF)
raw_local_irq_disable();
instrumentation_end();
next prev parent reply other threads:[~2025-02-24 12:46 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 12:37 [PATCH v4 00/10] x86/ibt: FineIBT-BHI Peter Zijlstra
2025-02-24 12:37 ` [PATCH v4 01/10] x86/cfi: Add warn option Peter Zijlstra
2025-02-24 18:57 ` Kees Cook
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` [tip: x86/core] x86/cfi: Add 'cfi=warn' boot option tip-bot2 for Peter Zijlstra
2025-02-24 12:37 ` [PATCH v4 02/10] x86/ibt: Add exact_endbr() helper Peter Zijlstra
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` tip-bot2 for Peter Zijlstra
2025-02-24 12:37 ` Peter Zijlstra [this message]
2025-02-24 18:58 ` [PATCH v4 03/10] x86/traps: Decode 0xEA #UD Kees Cook
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` [tip: x86/core] x86/traps: Decode 0xEA instructions as #UD tip-bot2 for Peter Zijlstra
2025-02-24 12:37 ` [PATCH v4 04/10] x86/traps: Allow custom fixups in handle_bug() Peter Zijlstra
2025-02-24 18:59 ` Kees Cook
2025-02-25 8:54 ` Peter Zijlstra
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` tip-bot2 for Peter Zijlstra
2025-02-24 12:37 ` [PATCH v4 05/10] x86/ibt: Optimize FineIBT sequence Peter Zijlstra
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` [tip: x86/core] x86/ibt: Optimize the FineIBT instruction sequence tip-bot2 for Peter Zijlstra
2025-02-24 12:37 ` [PATCH v4 06/10] x86/traps: Decode LOCK Jcc.d8 #UD Peter Zijlstra
2025-02-24 21:46 ` David Laight
2025-02-25 18:33 ` Kees Cook
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` [tip: x86/core] x86/traps: Decode LOCK Jcc.d8 as #UD tip-bot2 for Peter Zijlstra
2025-02-24 12:37 ` [PATCH v4 07/10] x86/ibt: Add paranoid FineIBT mode Peter Zijlstra
2025-02-24 19:00 ` Kees Cook
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` tip-bot2 for Peter Zijlstra
2025-02-24 12:37 ` [PATCH v4 08/10] x86: BHI stubs Peter Zijlstra
2025-02-24 19:01 ` Kees Cook
2025-02-25 8:52 ` Peter Zijlstra
2025-02-25 18:31 ` Kees Cook
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` [tip: x86/core] x86/bhi: Add " tip-bot2 for Peter Zijlstra
2025-02-26 12:54 ` tip-bot2 for Peter Zijlstra
2025-02-24 12:37 ` [PATCH v4 09/10] x86/ibt: Implement FineIBT-BHI mitigation Peter Zijlstra
2025-02-25 9:12 ` Peter Zijlstra
2025-02-26 0:04 ` Constable, Scott D
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` tip-bot2 for Peter Zijlstra
2025-02-26 12:54 ` tip-bot2 for Peter Zijlstra
2025-02-26 19:53 ` Peter Zijlstra
2025-03-10 8:55 ` Peter Zijlstra
2025-03-10 16:00 ` Miguel Ojeda
2025-03-10 16:02 ` Peter Zijlstra
2025-03-11 19:09 ` Ramon de C Valle
2025-03-11 19:41 ` Miguel Ojeda
2025-03-11 20:23 ` Ramon de C Valle
2025-03-12 9:16 ` Peter Zijlstra
2025-03-12 11:36 ` Miguel Ojeda
2025-03-19 0:04 ` Nathan Chancellor
2025-02-24 12:37 ` [PATCH v4 10/10] x86/ibt: Optimize fineibt-bhi arity 1 case Peter Zijlstra
2025-02-26 10:54 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2025-02-26 12:04 ` [tip: x86/core] x86/ibt: Optimize the " tip-bot2 for Peter Zijlstra
2025-02-26 12:54 ` tip-bot2 for 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=20250224124200.166774696@infradead.org \
--to=peterz@infradead.org \
--cc=alexei.starovoitov@gmail.com \
--cc=alyssa.milburn@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=hjl.tools@gmail.com \
--cc=jmill@asu.edu \
--cc=joao@overdrivepizza.com \
--cc=jose.marchesi@oracle.com \
--cc=jpoimboe@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=samitolvanen@google.com \
--cc=scott.d.constable@intel.com \
--cc=x86@kernel.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