From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 871403AB26D for ; Mon, 14 Sep 2026 23:06:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789427214; cv=none; b=m4/SZ7u7c0OoIzD9lDj8AJWa2gVAGzZ+jN2kYE3IHrHzT9K2NBK75ZmlU1zXfuAQrpMgrIkmeAPB7Lc1SWV9nW9+1HwhkevV9pAqN3KNyRPQFgZcBhxofPdQlBB7ESVviM3iA3MrWQcLSX1XUTt6FeEfcmoxD7cMYxCYwE/kvhg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789427214; c=relaxed/simple; bh=O/Vyyquoe8PAs/bXEMIJGZdXPAzwhVdbV6aQFeqCMwg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VGQY0ZCuIsp5MITrmXBwfkbNRHI5BrqqaGJIwm8s61fmGcBewV5PFj6sQ870PbwU0hinGZL348886OhZxZ3AE9G6ZHH4APNOBvWrhi4UALnR04IMKoPZHB9KpL8Ulb2UAHnSgl12uXzJvuqHv6jcPKroce/lifn5dfdzeLMYqYc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I4bF6uwi; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I4bF6uwi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A7E51F000FF; Mon, 14 Sep 2026 23:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789427213; bh=WV5VeW8fRzrqpwY3VtpGMwei4VK+vatQRHwjjgTf53I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I4bF6uwixZ+XKeB5BD0LxkSWL2TPR8DV862QmosaBe030TZ6KY695GGeliAJRpEuo kyWCjH4de8GFrvR3siqDjP/ceKYw3KC1obAqT0GHkE0VPWmy6TmCa5q7VVd3sapgo/ zA2TAz5eDdwI/4bzyJO5p+JRAHqV+LEfS5Y4yvKD1kSC/xp/J8lhE0jUZwUOMH2BN1 xV+C1YnRrD5Pwb4pcTHA1MRpfqFkj8yT4dhST6YiPZUsJzjIk36tQ7BmkTMcZsW9JL +/kT/SFU0xJVsW7okC3SsaVTFCmCwzp6f4fs80A/uVLNIfsebPXQohclLyCL/UnwiL 8KkKAN+UxIOjQ== From: Song Liu To: live-patching@vger.kernel.org Cc: jpoimboe@kernel.org, peterz@infradead.org, jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com, joe.lawrence@redhat.com, puranjay@kernel.org, kernel-team@meta.com, Song Liu Subject: [PATCH v3 35/58] objtool/klp: Add test for recorded checksum values Date: Mon, 14 Sep 2026 16:03:32 -0700 Message-ID: <20260914230355.3422996-36-song@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260914230355.3422996-1-song@kernel.org> References: <20260914230355.3422996-1-song@kernel.org> Precedence: bulk X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Whether klp diff treats a function as changed is decided by its checksum, and until now nothing looked at one. A test asserting only that the right functions were cloned cannot tell a correct checksum from one that happens to differ. Asserts both directions -- the changed function's checksum moves, the untouched one's does not -- and that checksumming identical input twice gives the same answer, since otherwise every rebuild reports spurious changes. Assisted-by: Claude:claude-opus-4 Based-on-test-by: Joe Lawrence Assisted-by: Claude:claude-opus-5 Signed-off-by: Song Liu --- .../tests/generic/test-checksum-value.sh | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 tools/objtool/tests/generic/test-checksum-value.sh diff --git a/tools/objtool/tests/generic/test-checksum-value.sh b/tools/objtool/tests/generic/test-checksum-value.sh new file mode 100755 index 000000000000..feae6a12e98d --- /dev/null +++ b/tools/objtool/tests/generic/test-checksum-value.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# The per-function checksums klp checksum records are what klp diff uses to +# decide which functions changed. A checksum covering too little misses a real +# change and the patch silently omits the function; one covering too much, or +# unstable across identical input, clones functions nobody patched and drags +# their dependencies in with them. +# +# test-basic covers which functions got cloned, which is downstream of this and +# passes for either kind of wrong checksum as long as the two errors do not +# happen to cancel. This checks the checksums themselves. + +. "$(dirname "$0")/../lib.sh" + +setup +build_pair basic.c + +assert_input_symbol changed +assert_input_symbol untouched + +run_checksum + +# The edited function's checksum has to move, the untouched one's must not. +assert_checksum_differs changed +assert_checksum_matches untouched + +# And it has to be a function of the code, not of the build: checksumming the +# same input twice has to give the same answer, or every rebuild reports +# spurious changes. +first="$(checksum_of orig.o changed)" +build_pair basic.c +run_checksum +[ "$(checksum_of orig.o changed)" = "$first" ] || + fail "checksum for 'changed' differs between builds of identical source" + +pass "checksums track the changed function and are stable across rebuilds" -- 2.53.0-Meta