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 8F31D4B515E for ; Fri, 11 Sep 2026 18:44:38 +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=1789152281; cv=none; b=ZpGVRXJt9vyZ+jPAyuzWPMf/ldISMqFR6i0yWXnHKfCe7lFRVY8D3omFD19Z+Cc+KH1G2MRP8FpvplGw+3TxRa4nReBy9PpqauWMzWyhUMi75dIJYhMYcR9tR1buZ8dhcdzr9zPF25QrT/xwDTOmBCsCSsm1MVnWycRRHEs5JKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789152281; c=relaxed/simple; bh=3t9WRMZC3WtGbhP1JpjLx0i5Vd0KR//kh+dHPQzlWkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jf8l3jaJXpM2zIgz9CZseT4qwLmH7TOzwuh+4SATuDJ60padc5vkF+PF9OBnM8r6W0R0x4SPLF+ZM2Zo2wkNgwrrGXjPNo8ui9dxo8czFOhXE/xW6lUxUgyWdwpSgfumr3bwZTmEud0T3X3GD54h3fxoy8kFs5dgHR5wHUsbWK4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GtFiwimq; 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="GtFiwimq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0337C1F000FF; Fri, 11 Sep 2026 18:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789152278; bh=rdkE/piEpaHExysLLETiJwi4o//fS58XpKis/FlZSq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GtFiwimq7iNchwrfbmVwIWWzFhpdOJSwHlQS2MeSXQRaCPN0C/9QQuuoyfk9hF+o8 D8HwFX60KjcZAtP44nqDoUoZM5l40cVkWgDeyqbDpaUl5im7L5hhc8wFMpd8W+50yk MDIxNhK+9xp31Dvlbi2RF+LBe7NoKdX281U+OwfpRMg/t9yWSRwBuENHJzFZYLlLiY /qRbKSUiCEwz8q736ui13oRESIuKf9pP4K+XUekDx5y84fpcYYpQnDWE/23hqOsRoL 31NzlEIMz+vQD9rFroxlr2JkUwA+FSum9vzJssAVw3rOupTIm26Z4xS7pzDeEdt13l ld3gpyqWo3C7g== 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 12/58] objtool/klp: Add test for rejecting changed data Date: Fri, 11 Sep 2026 11:42:19 -0700 Message-ID: <20260911184305.1457308-13-song@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260911184305.1457308-1-song@kernel.org> References: <20260911184305.1457308-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 From: Puranjay Mohan Livepatching replaces functions. Nothing can swap a variable which live code already refers to, so a patch which changes one has to be refused rather than applied with the old value left in place. Signed-off-by: Puranjay Mohan Assisted-by: Claude:claude-opus-5 Signed-off-by: Song Liu --- .../tests/generic/fixtures/changed_data.c | 16 ++++++++++++++++ .../objtool/tests/generic/test-changed-data.sh | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tools/objtool/tests/generic/fixtures/changed_data.c create mode 100755 tools/objtool/tests/generic/test-changed-data.sh diff --git a/tools/objtool/tests/generic/fixtures/changed_data.c b/tools/objtool/tests/generic/fixtures/changed_data.c new file mode 100644 index 000000000000..b52461835444 --- /dev/null +++ b/tools/objtool/tests/generic/fixtures/changed_data.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Data whose value differs between the two builds. */ + +static const char __modinfo[] + __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux"; + +#ifdef PATCHED +int klp_test_data = 2; +#else +int klp_test_data = 1; +#endif + +int target(int x) +{ + return x + klp_test_data; +} diff --git a/tools/objtool/tests/generic/test-changed-data.sh b/tools/objtool/tests/generic/test-changed-data.sh new file mode 100755 index 000000000000..c5c7381bb409 --- /dev/null +++ b/tools/objtool/tests/generic/test-changed-data.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Livepatching replaces functions, not data. A changed data symbol must be +# rejected. + +. "$(dirname "$0")/../lib.sh" + +setup +build_pair changed_data.c +run_diff 255 + +diff_log | grep -q 'changed data: klp_test_data' || + fail "expected rejection, got: $(diff_log | tail -1)" +[ -e "$workdir/out.o" ] && + fail "output object produced for a rejected input" + +pass "changed data symbol rejected" -- 2.53.0-Meta