From: sashiko-bot@kernel.org
To: "Longjun Luo" <luolongjuna@gmail.com>,
jpoimboe@kernel.org, peterz@infradead.org
Cc: mbenes@suse.cz, pmladek@suse.com, joe.lawrence@redhat.com,
song@kernel.org, puranjay@kernel.org, nathan@kernel.org,
ndesaulniers@google.com, morbo@google.com,
justinstitt@google.com, live-patching@vger.kernel.org
Subject: Re: [RFC PATCH 2/3] objtool/klp: Include symbol identities in reference checksums
Date: Mon, 26 Oct 2026 11:31:55 +0000 [thread overview]
Message-ID: <sashiko-outbox-185103@kernel.org> (raw)
In-Reply-To: <20261026101916.3823942-3-luolongjuna@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] objtool/klp: unstable checksums for local symbols in prepare_identities()
--
commit 547eafe74bd5b34cf5af6c927344337c25025230
Author: Longjun Luo <luolongjuna@gmail.com>
objtool/klp: Include symbol identities in reference checksums
This commit prepares symbol identities during klp checksum and hashes the
target symbol's source/scope/demangled_name path instead of only its
demangled name when computing instruction and data object reference
checksums.
> diff --git a/tools/objtool/klp-identity.c b/tools/objtool/klp-identity.c
> index 627eda694389e..ca8e65d5d3927 100644
> --- a/tools/objtool/klp-identity.c
> +++ b/tools/objtool/klp-identity.c
> @@ -156,12 +156,19 @@ int prepare_identities(struct elf *elf)
>
> for_each_sym(elf, sym) {
> struct identity *identity = &sym->identity;
> + char *path;
>
> /* Default to STT_FILE and "/" for missing DWARF information. */
> if (!identity->external && !*identity->source && sym->file)
> identity->source = sym->file->identity.source;
> if (!identity->scope)
> identity->scope = "/";
> + if (asprintf(&path, "%s%s%s", identity->source, identity->scope,
> + identity->demangled_name) < 0) {
> + ERROR_GLIBC("asprintf");
> + return -1;
> + }
> + identity->path = path;
[Severity: Medium]
Can baking sym->file->identity.source into identity->path cause unstable
reference checksums for unchanged functions and data objects when a livepatch
adds or removes the only correlated static symbol in a translation unit?
In cmd_klp_checksum(), sym->dont_correlate = dont_correlate(sym) is populated
before calling prepare_identities(file->elf). In prepare_identities(), the
first loop initializes each STT_FILE symbol's identity->source to sym->name
(typically a short basename such as "foo.c") and skips DWARF lookup whenever
is_dwarf_identity_candidate(sym) returns false:
tools/objtool/klp-identity.c:is_dwarf_identity_candidate() {
return !sym->dont_correlate && sym->len && !is_undef_sym(sym) &&
(is_func_sym(sym) || is_object_sym(sym));
}
In the second loop of prepare_identities(), external symbols clear
identity->source to "", and complete_file_source() only upgrades
sym->file->identity.source from the short STT_FILE name to the full
normalized DWARF compilation unit path when the translation unit contains at
least one correlated (!sym->dont_correlate), non-external STB_LOCAL symbol
with DWARF information:
tools/objtool/klp-identity.c:prepare_identities() {
...
if (identity->external)
identity->source = "";
else if (complete_file_source(sym, identity->source))
return -1;
...
}
In the third loop above, all local symbols without a DWARF identity (including
dont_correlate symbols such as .data..once flags from WARN_ONCE/DO_ONCE,
pr_debug descriptors, __func__, lockdep keys, switch tables, anonymous
rodata, and .altinstr_replacement symbols) fall back to
sym->file->identity.source and format it into identity->path, which is then
hashed by checksum_update_insn() and checksum_update_object().
If a translation unit in orig.o has only external symbols (or static symbols
that were all inlined or promoted to STB_GLOBAL by ThinLTO),
sym->file->identity.source remains the short STT_FILE name. If patched.o
then introduces a static helper or static variable in that translation unit
(or removes the last one), sym->file->identity.source flips between the short
STT_FILE name and the full DWARF path.
Wouldn't that change identity->path for every fallback and dont_correlate
local symbol in the translation unit, causing unchanged functions referencing
them to get different checksums and causing unchanged correlated data objects
referencing them to fail klp diff in mark_changed_functions() with a false
"changed data" error?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261026101916.3823942-1-luolongjuna@gmail.com?part=2
next prev parent reply other threads:[~2026-10-26 11:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 10:19 [RFC PATCH 0/3] objtool/klp: DWARF-based cross-build symbol correlation Longjun Luo
2026-10-26 10:19 ` [RFC PATCH 1/3] objtool/klp: Correlate symbols using DWARF identity Longjun Luo
2026-10-26 11:14 ` sashiko-bot
2026-10-26 10:19 ` [RFC PATCH 2/3] objtool/klp: Include symbol identities in reference checksums Longjun Luo
2026-10-26 11:31 ` sashiko-bot [this message]
2026-10-26 10:19 ` [RFC PATCH 3/3] objtool/klp: Test DWARF identities and " Longjun Luo
2026-10-28 20:24 ` [RFC PATCH 0/3] objtool/klp: DWARF-based cross-build symbol correlation Josh Poimboeuf
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-185103@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=justinstitt@google.com \
--cc=live-patching@vger.kernel.org \
--cc=luolongjuna@gmail.com \
--cc=mbenes@suse.cz \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=puranjay@kernel.org \
--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.