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

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

From: Song Liu <song@kernel.org>
Date: 2026-09-14 20:55:15
Also in: sashiko-reviews

On Sun, Sep 13, 2026 at 11:38 PM [off-list ref] wrote:
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
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
[ ... ]
quoted
+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?
Seems to be an issue introduced in v2. Fixing it in v3.

Thanks,
Song
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help