[Devel] [PATCH hci-8.2 14/17] ms/objtool/klp: Fix module name normalization for paths with dots
Eva Kurchatova
eva.kurchatova at virtuozzo.com
Tue Nov 24 08:01:03 MSK 2026
From: Josh Poimboeuf <jpoimboe at kernel.org>
When .modinfo has no "name=" tag, __find_modname() falls back to
converting the object's build-tree path to a runtime module name by
stripping directory components, converting '-' to '_' and truncating the
file extension.
It does all that in a single pass over the entire path, so the first dot
anywhere in the path ends the name. For an object built in a directory
whose name contains a dot, e.g. "drivers/foo-1.0/bar.o", the result is a
bogus module name.
Strip the directory components up front so only the basename is scanned
for the extension separator.
Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Reported-by: Sashiko <sashiko-bot at kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe at kernel.org>
Signed-off-by: Ingo Molnar <mingo at kernel.org>
Cc: live-patching at vger.kernel.org
Link: https://patch.msgid.link/9017b4609553bed16674e8f924d34691cbc2b2c1.1785727106.git.jpoimboe@kernel.org
(cherry picked from commit 165affd6f095323d953b0ed5823ec4d0db3b7d0d)
https://virtuozzo.atlassian.net/browse/VSTOR-128510
Feature: klp-build support
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
---
tools/objtool/klp-diff.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 2f1cedf9632b..c6f7c810f31a 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -712,7 +712,7 @@ static struct export *find_export(struct symbol *sym)
static const char *__find_modname(struct elfs *e)
{
struct section *sec;
- char *name;
+ char *name, *slash;
sec = find_section_by_name(e->orig, ".modinfo");
if (!sec) {
@@ -730,10 +730,12 @@ static const char *__find_modname(struct elfs *e)
return NULL;
}
+ slash = strrchr(name, '/');
+ if (slash)
+ name = slash + 1;
+
for (char *c = name; *c; c++) {
- if (*c == '/')
- name = c + 1;
- else if (*c == '-')
+ if (*c == '-')
*c = '_';
else if (*c == '.') {
*c = '\0';
--
2.56.1
More information about the Devel
mailing list