[tip: x86/core] x86/kcfi: Emit the FineIBT paranoid "cs" prefix as a byte
From: tip-bot2 for Kees Cook
Date: Mon Oct 12 2026 - 06:04:42 EST
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 41d1119e2f8577b4bd01d31321c6761af9140ce7
Gitweb: https://git.kernel.org/tip/41d1119e2f8577b4bd01d31321c6761af9140ce7
Author: Kees Cook <kees@xxxxxxxxxx>
AuthorDate: Mon, 12 Oct 2026 02:04:25 -07:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Mon, 12 Oct 2026 11:47:35 +02:00
x86/kcfi: Emit the FineIBT paranoid "cs" prefix as a byte
The "cs" prefix on the LEA in the FineIBT paranoid caller template is
padding: it places the LEA's 0xf0 immediate byte where it doubles as the
LOCK prefix that makes the failing Jcc raise #UD. GNU as warns about it
in every CONFIG_FINEIBT=y build:
Warning: segment override on `lea' is ineffectual
Clang's integrated assembler does not warn, and both assemble the same
bytes. Emit the prefix with ".byte 0x2e" to silence GNU as.
Build tested ARCH=x86_64 defconfig with CONFIG_CFI=y, with GCC 17.0.0
(experimental, with the kCFI series) and GNU as 2.47, and with Clang
24.0.0git: GNU as no longer warns, and the template assembles to the
same bytes as before with both. Under QEMU with cfi=fineibt,paranoid,
the paranoid caller check catches LKDTM's CFI_FORWARD_PROTO with both.
Assisted-by: LLM
Signed-off-by: Kees Cook <kees@xxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Link: https://patch.msgid.link/20261012090436.1676525-2-kees@xxxxxxxxxx
---
arch/x86/kernel/alternative.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 582c6d8..efbc11f 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -1455,7 +1455,8 @@ asm( ".pushsection .rodata \n"
"fineibt_paranoid_start: \n"
" mov $0x12345678, %eax \n"
" cmpl -11(%r11), %eax \n"
- " cs lea -0x10(%r11), %r11 \n"
+ " .byte 0x2e \n"
+ " lea -0x10(%r11), %r11 \n"
"#fineibt_caller_size: \n"
" jne fineibt_paranoid_start+0xd \n"
"fineibt_paranoid_ind: \n"