Thread (88 messages) flat view 88 messages, 2 authors, 5d ago

Re: [PATCH v2 16/58] objtool/klp: Add test for cold function halves

From: sashiko-bot@kernel.org
Date: 2026-09-14 06:38:33

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The test assertion for the carried cold function incorrectly passes with `llvm-readelf` when the cold half is left behind.
--

commit a04e65cdf7036d7ab3a10a22fc0efb8a0c3873bd
Author: Puranjay Mohan [off-list ref]

objtool/klp: Add test for cold function halves

The compiler splits unlikely code into a separate foo.cold symbol. Both
halves are the same function and both belong in the livepatch. This adds
a test to ensure cold paths branching into unpatched code are handled.
quoted hunk ↗ jump to hunk
diff --git a/tools/objtool/tests/generic/test-cold-function.sh b/tools/objtool/tests/generic/test-cold-function.sh
new file mode 100755
index 0000000000000..dd4a7297af044
--- /dev/null
+++ b/tools/objtool/tests/generic/test-cold-function.sh
[ ... ]
+assert_patched target
+# Not a bare name match: had the cold half been left behind, the branch to
+# it would appear as an undefined .klp.sym.vmlinux.target.cold, whose name
+# contains the one being looked for.  Require a defined symbol.
+out_symbols | awk '$7 != "UND" && $8 ~ /target\.cold/ { found = 1 }
+	END { exit !found }' ||
+	fail "cold half was not carried into the patch"
[Severity: Medium]
Will this awk script correctly detect missing cold halves when the test is
run with llvm-readelf?

When the cold half is left behind, klp diff converts unresolved references
into SHN_LIVEPATCH symbols. llvm-readelf formats these as:

OS[0xff20] .klp.sym.vmlinux.target.cold,0

Because there is no space between the section name and the symbol name in
this output format, $7 evaluates to "OS[0xff20]" (which is not "UND") and $8
matches the /target\.cold/ regex.

Does this condition evaluate to true and cause the test to falsely pass when
the cold half is actually left behind?
+
+pass "cold half carried into the patch with its parent"
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260914062514.926997-1-song@kernel.org?part=16
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help