kernel/livepatch/core.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
A possible issue with the kpatch software was discovered during testing
in the 6.6 and above kernel:
livepatch: symbol .klp.sym.vmlinux-bringup_idt_table,5438511 has an
incorrectly formatted name.
The "-" between ".vmlinux-bringup_idt_table" cannot be parsed in the
current kernel. Of course, this is a problem generated by the kpatch
software.
Perhaps, we could adopt the approach in the patch to skip the error
symbols compiled by kpatch.
Signed-off-by: Li kunyu <likunyu10@163.com>
---
kernel/livepatch/core.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 0e73fac55f8e..74b07a1b6c1f 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -199,6 +199,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab,
unsigned long sympos, addr;
bool sym_vmlinux;
bool sec_vmlinux = !strcmp(sec_objname, "vmlinux");
+ bool reload = false;
/*
* Since the field widths for sym_objname and sym_name in the sscanf()
@@ -227,12 +228,32 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab,
".klp.sym.%55[^.].%511[^,],%lu",
sym_objname, sym_name, &sympos);
if (cnt != 3) {
- pr_err("symbol %s has an incorrectly formatted name\n",
- strtab + sym->st_name);
- return -EINVAL;
+ if (strchr(strtab + sym->st_name, '-')) {
+ memset(sym_objname, 0, strlen(sym_objname));
+ memset(sym_name, 0, strlen(sym_name));
+ cnt = sscanf(strtab + sym->st_name,
+ ".klp.sym.%55[^-]-%511[^,],%lu",
+ sym_objname, sym_name, &sympos);
+ if (cnt != 3) {
+ pr_err("symbol %s has an incorrectly formatted name, " \
+ "cnt=%d, sym_objname:%s, sym_name:%s\n",
+ strtab + sym->st_name, cnt, sym_objname, sym_name);
+ return -EINVAL;
+ }
+ reload = true;
+ sympos = 1;
+ } else {
+
+ pr_err("symbol %s has an incorrectly formatted name\n",
+ strtab + sym->st_name);
+ return -EINVAL;
+ }
}
- sym_vmlinux = !strcmp(sym_objname, "vmlinux");
+ if (!reload)
+ sym_vmlinux = !strcmp(sym_objname, "vmlinux");
+ else
+ sym_vmlinux = sec_vmlinux;
/*
* Prevent module-specific KLP rela sections from referencing
--
2.47.3
On 7/20/25 4:50 PM, Li kunyu wrote: > A possible issue with the kpatch software was discovered during testing > in the 6.6 and above kernel: > livepatch: symbol .klp.sym.vmlinux-bringup_idt_table,5438511 has an > incorrectly formatted name. > Hmm, how did the dash get in the symbol name? If I build a defconfig x86_64 kernel from today, I see the "bringup_idt_table" symbol in vmlinux, but as per Documentation/livepatch/module-elf-format.rst shouldn't it be: .klp.sym.vmlinux.bringup_idt_table,<sympos> (which btw, sympos of 5438511 seems a little bit large?) Can you reference which kpatch-build project you are using (there are several forks floating around, plus downstream versions) and then how to reproduce this. Thanks! -- Joe
After investigation, it was confirmed that the issue was indeed caused by the code added to the kpatch software by the community I joined, as stated in the patch: 1. Add a new code branch to solve the following problem. Due to the parsing of a certain symbol name, for example, if the symbol name exceeds 128 bytes, it is pieced together as.klp.sym.xxxx-xxxx,< symbol offset positiIon >. 2. Due to the code added by kpatch not being compatible with the kernel, issues were raised. This is a mistake made by the community, they have already fixed kpatch and custom kernel. Thanks.
After investigation, it was confirmed that the issue was indeed caused by the code added to the kpatch software by the community I joined, as stated in the patch: 1. Add a new code branch to solve the following problem. Due to the parsing of a certain symbol name, for example, if the symbol name exceeds 128 bytes, it is pieced together as.klp.sym.xxxx-xxxx,< symbol offset positiIon >. 2. Due to the code added by kpatch not being compatible with the kernel, issues were raised. This is a mistake made by the community, they have already fixed kpatch and custom kernel. Thanks.
© 2016 - 2025 Red Hat, Inc.