From: sashiko-bot@kernel.org
To: live-patching@vger.kernel.org
Cc: "Jiri Kosina" <jikos@kernel.org>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
"Song Liu" <song@kernel.org>, "Petr Mladek" <pmladek@suse.com>,
"Miroslav Benes" <mbenes@suse.cz>,
"Ben Procknow" <bprockno@redhat.com>
Subject: Re: [PATCH 1/1] objtool/klp: fix symbol ordering for data symbols
Date: Fri, 10 Jul 2026 15:40:33 +0000 [thread overview]
Message-ID: <20260710154033.AB1A31F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260710153042.3156788-2-joe.lawrence@redhat.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The new multi-pass sympos calculation for data symbols hardcodes an incorrect section ordering that prioritizes `.data..ro_after_init` over `.rodata`, and lumps other distinct data sections together, failing to match kallsyms address ordering.
Pre-existing issues:
- [High] Calculating `sympos` for cross-type duplicates (e.g., a function and a variable sharing the same name) yields contradictory results because the iteration passes diverge based on the queried symbol's type without filtering the counted symbols.
--
--- Patch [1]: [PATCH 1/1] objtool/klp: fix symbol ordering for data symbols ---
commit c98091d5ce8ba2d91968d3bbc6e227ed2bf27934
Author: Joe Lawrence <joe.lawrence@redhat.com>
objtool/klp: fix symbol ordering for data symbols
The find_sympos() function calculates a sympos (symbol position) used by
livepatch to disambiguate duplicate symbol names. This commit extends the
existing section ordering workaround to handle data symbols, counting
.data..ro_after_init first, then other .data, then .bss.
> diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
> index f8787d7d14547..034778885e922 100644
> --- a/tools/objtool/klp-diff.c
> +++ b/tools/objtool/klp-diff.c
> @@ -873,6 +873,8 @@ static unsigned long find_sympos(struct elf *elf, struct symbol *sym)
>
> if (sym->bind != STB_LOCAL)
> return 0;
>
> if (vmlinux && is_func_sym(sym)) {
[Severity: High]
This is a pre-existing issue, but does this logic cause collisions when a
function and a variable share the same name?
The branches here decide which sections are prioritized during counting based
on the queried symbol's type (is_func_sym vs is_object_sym). However, the
inner loops count all duplicates blindly by name without filtering the counted
symbols by type.
If there is a cross-type duplicate, the function and the variable could each
be found first during their respective queries because the passes iterate
sections in different orders. Would this result in both getting the exact same
sympos?
Since klp_find_object_symbol doesn't filter by type in the kernel, could a
request to patch the variable erroneously resolve to the function?
[ ... ]
> @@ -905,6 +907,46 @@ static unsigned long find_sympos(struct elf *elf, struct symbol *sym)
> has_dup = true;
> }
> }
> + } else if (vmlinux && is_object_sym(sym)) {
> + /*
> + * HACK: Similarly, data symbol ordering can differ between
> + * vmlinux.o and vmlinux. The linker script places sections:
> + * .data..ro_after_init (lowest address)
> + * .data* sections
> + * .bss* sections (highest address)
> + * Count in that order.
> + */
[Severity: High]
Does this hardcoded section ordering match the actual kallsyms address
ordering?
In the kernel linker script, .rodata is placed before RO_AFTER_INIT_DATA,
meaning .rodata symbols will appear before .data..ro_after_init symbols since
kallsyms sorts strictly by address.
If a livepatch contains duplicate static data symbols where one is in .rodata
and another is in .data..ro_after_init, this patch will count
.data..ro_after_init first.
Could this assign sympos=1 to the .data..ro_after_init symbol and sympos=2 to
the .rodata symbol, causing livepatch to patch the wrong variable when it asks
for sympos=2?
> + for_each_sym(elf, s) {
> + if (strstarts(s->sec->name, ".data..ro_after_init") &&
> + !strcmp(s->name, sym->name)) {
> + nr_matches++;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260710153042.3156788-1-joe.lawrence@redhat.com?part=1
prev parent reply other threads:[~2026-07-10 15:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 15:30 [PATCH 0/1] Mitigate klp-build data sympos bug Joe Lawrence
2026-07-10 15:30 ` [PATCH 1/1] objtool/klp: fix symbol ordering for data symbols Joe Lawrence
2026-07-10 15:40 ` sashiko-bot [this message]
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=20260710154033.AB1A31F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bprockno@redhat.com \
--cc=jikos@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=song@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.