From nobody Mon Oct 6 13:38:22 2025 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE50C2D372F; Thu, 24 Jul 2025 12:41:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753360878; cv=none; b=nSb0fUDfjUNPsufQUVw5WuRhi9xyJCV5/1k0Ha9jDPUMIieZCedUbeZHooC5oXVkb6M0WSxrL4C/jSDeHt20OIzRhEVq8JeaIp+avwj62fv0P+Rb8IslpF6/N2yaMtBhmdepDNQY6iQx/lakn05cg9vhrezcW+nDgT3npyvbgRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753360878; c=relaxed/simple; bh=1wVxn+mTLzWPG3baEb7/Dr1ogBzjVZqcLlpZam049Ms=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lOI8bynt8DiYww7P98cMkAPBP/8E38B1LIE5Z4HByePUL+GPfOwjc6VEOHChnCtpQCIPZsATiUzpuZU/2KmDb5oq6RbKqmaeWxmmytYiyfD1kprowhu3eJ1LDMtm3Zmeb50gasPAynnmNouPXJFBzRGd6ge42kPOIHeEOtLLVlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=jWn51Vc2; arc=none smtp.client-ip=220.197.31.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="jWn51Vc2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Zl c6/SAN3mXOw2kV24g78sQnlu6LMHoK+teDO96CRyU=; b=jWn51Vc2imLtJ0sFIr fFTLh9m6az99d3HBETM/Sk2LMJEHZJBkYAnxX9liWQPXcU5PUqM/cEiet0EpEW+V CQuqcbF/fDqEolMjA+k1wZATTf8GGSVWPL2R/ev58NrMq97ncUf8GNvPvp42/tLy 5GzYOaEtK2aDpgO4PhtHTkkgI= Received: from vbox.. (unknown []) by gzsmtp4 (Coremail) with SMTP id PygvCgCX9u_PKYJoBIO7Ag--.46530S2; Thu, 24 Jul 2025 20:40:48 +0800 (CST) From: Li kunyu To: jpoimboe@kernel.org, jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com, joe.lawrence@redhat.com Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Li kunyu Subject: [PATCH] kernel/livepatch/core: Fixed the issue of parsing failure caused by symbols carrying '-' generated by the kpatch software Date: Mon, 21 Jul 2025 04:50:59 +0800 Message-ID: <20250720205059.138877-1-likunyu10@163.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: PygvCgCX9u_PKYJoBIO7Ag--.46530S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJr43uw4xKr4xGF4kCw1UGFg_yoW8tF1xpr WrA345Zw4xJ342gF4fJr45Cr15Jwn7Xa18Ka9rJr1kAw43Z34rAr4kWFWY9as8JryfGayY qF4SyFWFk34kJ37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07Uq1vhUUUUU= X-CM-SenderInfo: poln30d1xriqqrwthudrp/xtbBzwyUpGiCJfk-7wAAsV Content-Type: text/plain; charset="utf-8" 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 --- 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 =3D !strcmp(sec_objname, "vmlinux"); + bool reload =3D false; =20 /* * 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, con= st char *strtab, ".klp.sym.%55[^.].%511[^,],%lu", sym_objname, sym_name, &sympos); if (cnt !=3D 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 =3D sscanf(strtab + sym->st_name, + ".klp.sym.%55[^-]-%511[^,],%lu", + sym_objname, sym_name, &sympos); + if (cnt !=3D 3) { + pr_err("symbol %s has an incorrectly formatted name, " \ + "cnt=3D%d, sym_objname:%s, sym_name:%s\n", + strtab + sym->st_name, cnt, sym_objname, sym_name); + return -EINVAL; + } + reload =3D true; + sympos =3D 1; + } else { + + pr_err("symbol %s has an incorrectly formatted name\n", + strtab + sym->st_name); + return -EINVAL; + } } =20 - sym_vmlinux =3D !strcmp(sym_objname, "vmlinux"); + if (!reload) + sym_vmlinux =3D !strcmp(sym_objname, "vmlinux"); + else + sym_vmlinux =3D sec_vmlinux; =20 /* * Prevent module-specific KLP rela sections from referencing --=20 2.47.3