Live Patching
 help / color / mirror / Atom feed
* [PATCH] objtool/klp: Build x86 test fixtures with -fcf-protection=none
@ 2026-12-01 15:17 Seke Kazuru
  2026-12-01 22:34 ` Josh Poimboeuf
  0 siblings, 1 reply; 2+ messages in thread
From: Seke Kazuru @ 2026-12-01 15:17 UTC (permalink / raw)
  To: joe.lawrence
  Cc: live-patching, jpoimboe, mbenes, pmladek, song, peterz,
	linux-kernel

x86 kernels always choose -fcf-protection themselves: =branch with
CONFIG_X86_KERNEL_IBT, =none without (arch/x86/Makefile).  The test
fixtures pass neither, so they get the compiler's default, and Ubuntu's
gcc defaults to =full.  That puts an ENDBR at the start of a global
function but not of a static one, so a patch which only changes a
function's linkage changes its code.

test-local-to-global-flip makes exactly that change and fails with
Ubuntu's gcc 11 to 14: flipped_up gains an ENDBR, klp diff rightly
reports it as changed and clones it, and the test, which expects it to
be correlated, fails.

Build the fixtures for the kernel without IBT, as the kernel would.  A
test about IBT can still override it.

Verified with Ubuntu gcc 11, 13 and 14, Debian gcc 16 and Clang 18 and
23: test-local-to-global-flip fails on the three Ubuntu compilers before
this change and passes after it, and no other test changes on any of
the six.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Seke Kazuru <kazuruuni@gmail.com>
---
 tools/objtool/tests/lib.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/objtool/tests/lib.sh b/tools/objtool/tests/lib.sh
index 4da168d0dd..41048960f8 100644
--- a/tools/objtool/tests/lib.sh
+++ b/tools/objtool/tests/lib.sh
@@ -153,6 +153,15 @@ EOF
 FIXTURE_CFLAGS="-O2 -ffunction-sections -fdata-sections -fno-common \
 		-fno-asynchronous-unwind-tables"
 
+# x86 kernels always choose -fcf-protection themselves (arch/x86/Makefile):
+# =branch with CONFIG_X86_KERNEL_IBT, =none without.  A compiler's default never
+# reaches kernel code, and some distributions' gcc defaults to =full, which puts
+# an ENDBR at the start of a global function but not of a static one -- so a
+# patch which only changes a function's linkage would change its code.  Stand
+# in for the kernel without IBT; a test about IBT overrides it.
+[ "$KLP_TEST_ARCH" != x86 ] ||
+	FIXTURE_CFLAGS="$FIXTURE_CFLAGS -fcf-protection=none"
+
 test_name="$(basename "$0" .sh)"
 workdir=
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01 22:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 15:17 [PATCH] objtool/klp: Build x86 test fixtures with -fcf-protection=none Seke Kazuru
2026-12-01 22:34 ` Josh Poimboeuf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox