Live Patching
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wilson Felipe Pereira" <wfelipe@google.com>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Miroslav Benes" <mbenes@suse.cz>,
	"Petr Mladek" <pmladek@suse.com>,
	"Joe Lawrence" <joe.lawrence@redhat.com>,
	"Song Liu" <song@kernel.org>
Cc: live-patching@vger.kernel.org,
	"Dylan Hatch" <dylanbhatch@google.com>,
	"Yi Zhu" <chuyee@google.com>
Subject: Re: [PATCH 1/2] objtool/klp: Disambiguate global symbols colliding with local symbols
Date: Tue, 17 Nov 2026 00:25:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-217999@kernel.org> (raw)
In-Reply-To: <20261117000835.1992893-2-wfelipe@google.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] objtool/klp: inflated module sympos in klp_find_sympos() [1]
--

commit 26d2979f735e7ba2e445358f238d7b4e6e36d856
Author: Wilson Felipe Pereira <wfelipe@google.com>

objtool/klp: Disambiguate global symbols colliding with local symbols

This commit teaches objtool's livepatch symbol handling to emit .klp.symid
entries and compute symbol positions for defined non-local symbols when
duplicate names exist in the object.

> diff --git a/tools/objtool/klp-sympos.c b/tools/objtool/klp-sympos.c
> index dfca9dd746812..087892ef35934 100644
> --- a/tools/objtool/klp-sympos.c
> +++ b/tools/objtool/klp-sympos.c
> @@ -381,14 +381,14 @@ unsigned long klp_find_sympos(struct elf *elf, struct symbol *sym)
>  	bool has_dup = false;
>  	struct symbol *s;
>  
> +	if (is_undef_sym(sym))
> +		return 0;
> +
>  	if (is_init_sym(sym)) {
>  		ERROR("%s: can't patch or reference init code/data", sym->name);
>  		return ULONG_MAX;
>  	}
>  
> -	if (sym->bind != STB_LOCAL)
> -		return 0;
> -
>  	/*
>  	 * vmlinux: the final link reorders symbols relative to vmlinux.o,
>  	 * so the position needs to be derived from the linked orig vmlinux via
> @@ -403,6 +403,9 @@ unsigned long klp_find_sympos(struct elf *elf, struct symbol *sym)
>  	 * module_kallsyms_on_each_symbol().
>  	 */
>  	for_each_sym(elf, s) {
> +		if (is_sec_sym(s) || is_file_sym(s) || is_undef_sym(s) ||
> +		    !(s->sec->sh.sh_flags & SHF_ALLOC))
> +			continue;

[Severity: Medium]
This problem wasn't introduced by this patch, but should this filter also
skip is_init_sym(s) [1]?

The module loader excludes .init symbols when building core_kallsyms, which
module_kallsyms_on_each_symbol() walks at runtime.  If a module has an
.init symbol with the same name as sym, counting it here inflates sympos so
the livepatch either fails to resolve the symbol at load time or binds to
the wrong occurrence.

[1] https://sashiko.dev/#/bug/linux-f8712b9c-c02a-4a37-83a3-92848caee298

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117000835.1992893-1-wfelipe@google.com?part=1

  reply	other threads:[~2026-11-17  0:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  0:08 [PATCH 0/2] objtool/klp: Fix sympos for global/local symbol collisions Wilson Felipe Pereira
2026-11-17  0:08 ` [PATCH 1/2] objtool/klp: Disambiguate global symbols colliding with local symbols Wilson Felipe Pereira
2026-11-17  0:25   ` sashiko-bot [this message]
2026-11-17  0:08 ` [PATCH 2/2] objtool/klp: Add test for global/local symbol name collisions Wilson Felipe Pereira

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-217999@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=chuyee@google.com \
    --cc=dylanbhatch@google.com \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=song@kernel.org \
    --cc=wfelipe@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox