From nobody Fri Sep 25 00:05:08 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 747324DDB32; Fri, 18 Sep 2026 10:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789726518; cv=none; b=KLu3U6uGoN1+9PPueQQ47JR8ezbFiTvfxRtmt7YBujYjwj0q7BH8wHe6walG5+eYQd/lN9RX+dvU6RxPTT2duRL9OEAQvciWqzZGvuRNT3jQ8VFGzH+9CHvNXF2FFVrVnc38VCIVz5eIGrfFCam2y/2FHr2tFjjK8fl/e3H65l8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789726518; c=relaxed/simple; bh=IhAzckqXusICLnx/SIGNB736Ibv7rgfLXnpWmPcUgas=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=I1uFIJALkQrqzi6I1KSOqa+jGh8zmULEr8ZsARtwnqqJd2qHfJVbVz4bR+AjepwLs3EwbtnEaBNOFqvZwTXzVilqjp6ZF4ZA1eMPfhj5AVqV4biLSEi474by3pFgnAzjMUp60xJheChmIaR8G8qmgOKvMQUxs6J1aZF7GRwUoug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=L8r8ZSjO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JOBByzs7; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="L8r8ZSjO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JOBByzs7" Date: Fri, 18 Sep 2026 10:15:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1789726513; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xg5yzzheooMpecebjjWjqmF+dLyTTpeGNJjNBNr0e3k=; b=L8r8ZSjOGz4UiFv+XRhtJ0r6IZMKRLpwLd/8nd0xLL9dsDdWGU58uhSKZhYDDhEiYuu/hX EFclHqKp56BydzA6TEksNZBmXVes/NWS9Xn//Ax2sWvi/gJzOmA3x3HmAj54I8csOWHSt4 0YJICxB4eBSMPlO0Tq/8tI3+tcBzrWK9SbPELKOGi23J9jTnUeY+B408NCckrPgidact82 /aDowomL6KY8uNRTO+rm5+P5oDf7gXsRbORaRCWgpvsUybEI6l1I6DfwVY1XXlsoDlIBMI qDjRZK9doIc+99CD1u+mQQogbaJdfR32q0sTofVtzS6xBRmEYvTh8byjSBCkeA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1789726513; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xg5yzzheooMpecebjjWjqmF+dLyTTpeGNJjNBNr0e3k=; b=JOBByzs74bLfvlUyTqNVx9M92IQLmnQg5espvsfevzJPsbB2Ma86xxxUCA/CG6KQHikg7L qqSkupdB3EyyW3Bw== From: "tip-bot2 for Song Liu" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool/klp: Test rejection of a file-local static branch key Cc: Song Liu , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260916184351.2720310-44-song@kernel.org> References: <20260916184351.2720310-44-song@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178972651159.1720534.6938958020872518767.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the objtool/core branch of tip: Commit-ID: 475d519928998c988a9972c45f0416e91e2fa281 Gitweb: https://git.kernel.org/tip/475d519928998c988a9972c45f0416e91= e2fa281 Author: Song Liu AuthorDate: Wed, 16 Sep 2026 11:43:36 -07:00 Committer: Josh Poimboeuf CommitterDate: Wed, 16 Sep 2026 17:21:45 -07:00 objtool/klp: Test rejection of a file-local static branch key A static branch key owned by a module cannot be reached with a klp reloc: late module patching allows the livepatch module to load first, leaving the __jump_table entry unresolved for jump_label_add_module() to dereference. validate_special_section_klp_reloc() rejects it at build time. test-jump-label-module-key covers that for a global key. A file-local one takes a different route to the same check: the compiler references a static through its section symbol plus an addend, so the key has to be resolved from the section before it can be recognised as STT_OBJECT at all. Until commit f9fb44b0ecef ("objtool/klp: Fix detection of corrupt static branch/call entries") it was not, and the reference was silently emitted. Give the fixture a STATIC_KEY knob and cover it. The test checks that the input really does reference the key through its section, since without that it is only a second copy of the existing test. Verified by reverting commit f9fb44b0ecef ("objtool/klp: Fix detection of corrupt static branch/call entries"): klp diff accepts the input and the test fails, under both gcc and clang. Assisted-by: Claude:claude-opus-4 Based-on-test-by: Joe Lawrence Assisted-by: Claude:claude-opus-5 Signed-off-by: Song Liu Link: https://patch.msgid.link/20260916184351.2720310-44-song@kernel.org Signed-off-by: Josh Poimboeuf --- tools/objtool/tests/generic/test-jump-label-module-static-key.sh | 45 ++++= +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 tools/objtool/tests/generic/test-jump-label-module-stat= ic-key.sh diff --git a/tools/objtool/tests/generic/test-jump-label-module-static-key.= sh b/tools/objtool/tests/generic/test-jump-label-module-static-key.sh new file mode 100755 index 0000000..7bdcbaf --- /dev/null +++ b/tools/objtool/tests/generic/test-jump-label-module-static-key.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# A static branch key owned by a module is rejected whether the key is glo= bal +# or file-local. +# +# The rejection matters because late module patching allows the livepatch +# module to load before the module it depends on: the __jump_table klp rel= oc is +# then unresolved, and jump_label_add_module() dereferences an uninitializ= ed +# pointer. Catching it at build time is the only defence. +# +# test-jump-label-module-key covers the global key. A file-local one reac= hes +# the same check by a different route: the compiler emits the reference ag= ainst +# the section symbol plus an addend, so validate_special_section_klp_reloc= () +# has to resolve it to the underlying object before it can see a key at al= l. +# Until it did, a static key was passed over as "not STT_OBJECT" and the +# unsupported reference was emitted with nothing said. +# +# Fixed by f9fb44b0ecef ("objtool/klp: Fix detection of corrupt static +# branch/call entries"). + +. "$(dirname "$0")/../lib.sh" + +setup +build_pair jump_label.c -DSTATIC_KEY -DMODNAME=3D'"klp_testmod"' + +require_input_section __jump_table + +# The premise: the key is reached through its section symbol, not by name. +# Without that this is just a second copy of test-jump-label-module-key. +input_jump_relocs=3D"$(in_relocs orig.o | awk '/rela__jump_table/,/^$/')" + +echo "$input_jump_relocs" | grep -q klp_test_key || + fail "fixture produced no __jump_table reference to the key" +echo "$input_jump_relocs" | grep -qE '\.(bss|data)\.klp_test_key' || + probe_skip "compiler referenced the static key by name, not through its s= ection" + +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 file-local static branch key rejected"