lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250720205059.138877-1-likunyu10@163.com>
Date: Mon, 21 Jul 2025 04:50:59 +0800
From: Li kunyu <likunyu10@....com>
To: jpoimboe@...nel.org,
	jikos@...nel.org,
	mbenes@...e.cz,
	pmladek@...e.com,
	joe.lawrence@...hat.com
Cc: live-patching@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Li kunyu <likunyu10@....com>
Subject: [PATCH] kernel/livepatch/core: Fixed the issue of parsing failure caused by symbols carrying '-' generated by the kpatch software

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@....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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ