[tip: objtool/core] objtool/klp: Add test for rejecting module-owned static branch keys
From: tip-bot2 for Puranjay Mohan
Date: Mon Sep 21 2026 - 05:37:16 EST
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: bd5e5fc7d6456e0669f47a3e10150ad05ae9d249
Gitweb: https://git.kernel.org/tip/bd5e5fc7d6456e0669f47a3e10150ad05ae9d249
Author: Puranjay Mohan <puranjay@xxxxxxxxxx>
AuthorDate: Wed, 16 Sep 2026 11:43:13 -07:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Mon, 21 Sep 2026 11:04:58 +02:00
objtool/klp: Add test for rejecting module-owned static branch keys
A static branch key belonging to a module cannot be reached with a klp
relocation: the patch may be applied after that module's static branch init
has run, which corrupts the code. Emitting one anyway produces a module
which loads and then BUG()s the first time the key changes state, so klp
diff has to refuse it.
The fixture differs from the accepted case only in the module name recorded
in .modinfo.
Signed-off-by: Puranjay Mohan <puranjay@xxxxxxxxxx>
Signed-off-by: Song Liu <song@xxxxxxxxxx>
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Assisted-by: Claude:claude-opus-5
Link: https://patch.msgid.link/20260916184351.2720310-21-song@xxxxxxxxxx
---
tools/objtool/tests/generic/test-jump-label-module-key.sh | 22 +++++++-
1 file changed, 22 insertions(+)
create mode 100755 tools/objtool/tests/generic/test-jump-label-module-key.sh
diff --git a/tools/objtool/tests/generic/test-jump-label-module-key.sh b/tools/objtool/tests/generic/test-jump-label-module-key.sh
new file mode 100755
index 0000000..7c3f82c
--- /dev/null
+++ b/tools/objtool/tests/generic/test-jump-label-module-key.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# A static branch key owned by a module cannot be reached with a klp
+# relocation and must be rejected.
+
+. "$(dirname "$0")/../lib.sh"
+
+setup
+build_pair jump_label.c -DMODNAME='"klp_testmod"'
+
+has_input_section orig.o __jump_table ||
+ probe_skip "fixture produced no __jump_table on this arch"
+
+run_diff 255
+
+diff_log | grep -q 'unsupported static branch key klp_test_key' ||
+ fail "expected rejection, got: $(diff_log | tail -1)"
+[ -e "$workdir/out.o" ] &&
+ fail "output object produced for a rejected input"
+
+pass "module-owned static branch key rejected"