Re: [PATCH v2 36/58] objtool/klp: Add test for position-independent checksums
From: sashiko-bot@kernel.org
Date: 2026-09-14 06:46:52
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The test script incorrectly assumes that if target() moves relative to the section start, its relative displacement to callee() must have changed. This allows the test to falsely pass if the compiler shifts both functions by the same amount.
--
commit 3328da26fa650b64515b357106fb0c92f158e5b7
Author: Song Liu [off-list ref]
objtool/klp: Add test for position-independent checksums
A function that only moves has not changed, and its checksum must not move
with it. This commit adds a test to verify position-independent checksums for
non-relocated jumps/calls.
quoted hunk ↗ jump to hunk
diff --git a/tools/objtool/tests/generic/test-checksum-position.sh b/tools/objtool/tests/generic/test-checksum-position.sh new file mode 100755 index 0000000000000..459a718d75e7e --- /dev/null +++ b/tools/objtool/tests/generic/test-checksum-position.sh
[ ... ]
+orig_off="$(in_symbols orig.o | awk '$8 == "target" { print $2 }')"
+new_off="$( in_symbols patched.o | awk '$8 == "target" { print $2 }')"
+[ -n "$orig_off" ] && [ -n "$new_off" ] ||
+ fail "target symbol not found in both objects"
+[ "$orig_off" != "$new_off" ] ||
+ probe_skip "compiler did not move target() between builds"
[Severity: Medium]
Does this check guarantee the relative displacement between target() and
callee() actually changed?
Since the test is built with -O2 (which enables -ftoplevel-reorder) and
-fno-function-sections, the compiler could group globals and statics,
emitting padding() before both target() and callee(). In this case, target()
and callee() would both shift by the exact size of padding().
The script checks if target() moved relative to the section start:
[ "$orig_off" != "$new_off" ]
This would evaluate to true since target() did move, allowing the test to
proceed. However, because the relative displacement between target() and
callee() is unchanged, the encoded call displacement bytes within target()
will be identical in both builds. The checksum will trivially match without
exercising objtool's displacement-masking logic.
+ +assert_checksum_matches target + +pass "checksum unchanged when the function only moves"
-- Sashiko AI review · https://sashiko.dev/#/patchset/20260914062514.926997-1-song@kernel.org?part=36