Thread (69 messages) 69 messages, 2 authors, 12d ago

Re: [PATCH v4 06/58] objtool/klp: Grow the klp test harness vocabulary

From: Song Liu <song@kernel.org>
Date: 2026-09-16 17:33:18
Also in: sashiko-reviews

On Tue, Sep 15, 2026 at 4:50 PM [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] objtool: syntax error in re_quote() sed substitution
--

commit d250ad3b119a644d241a85f86850556fd200db22
Author: Song Liu [off-list ref]

objtool/klp: Grow the klp test harness vocabulary

Assertions for what klp diff produces, and for what went into it.
The output side covers the things a livepatch is made of: cloned sections
and symbols, klp symbols and their sympos, tombstones, and relocations.
quoted
diff --git a/tools/objtool/tests/lib.sh b/tools/objtool/tests/lib.sh
index 9330d839ff850..ffc1efb06233c 100644
--- a/tools/objtool/tests/lib.sh
+++ b/tools/objtool/tests/lib.sh
[ ... ]
quoted
+# re_quote <string>
+#
+# A string as a literal basic regular expression.  Nearly every name these
+# assertions match on contains a dot -- .text.target, .klp.rela.vmlinux -- and
+# an unescaped dot matches any character, so an assertion for one section can be
+# satisfied by a different one whose name merely lines up.
+re_quote() { printf '%s' "$1" | sed 's/[].[^$*\\/]/\\&/g'; }
[Severity: Medium]
Will this sed substitution work correctly in POSIX, GNU, and BSD sed?

The command sed 's/[].[^$*\\/]/\\&/g' is invalid because the delimiter
scanner processes \/ as an escaped backslash followed by an unescaped slash.
It treats this slash as the end of the regular expression prematurely, which
results in a syntax error like 'unknown option to s' or 'unterminated
s command'.

This failure causes re_quote() to return an empty string, which makes
assertions like assert_section silently pass by matching any two consecutive
spaces in readelf output, and others like assert_klp_sym consistently fail.
I am not sure this is a real issue. But we wil change to something like

re_quote() { printf '%s' "$1" | sed 's|[].[^$*\\/]|\\&|g'; }

in v5.

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