From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Longjun Luo <luolongjuna@gmail.com>
Cc: peterz@infradead.org, 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,
llvm@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 01/11] objtool/klp: Fix checksums and copying of wide strings
Date: Thu, 12 Nov 2026 18:42:36 -0800 [thread overview]
Message-ID: <avZ3jEbnuVu5Qv2G@jpoimboe> (raw)
In-Reply-To: <20261104133158.3187525-2-luolongjuna@gmail.com>
On Wed, Nov 04, 2026 at 09:31:47PM +0800, Longjun Luo wrote:
> SHF_STRINGS sections can contain elements wider than one byte. Using
> strlen() truncates their contents at an embedded zero byte, hiding
> changes and copying incomplete strings into the patch.
>
> Find the terminating zero element using sh_entsize. Use the resulting
> length for both reference checksums and copying, and propagate errors
> through checksum calculation. Keep single-byte string handling unchanged.
>
> Add a test for two- and four-byte strings, including references from data.
>
> Validated the available objtool tests with GCC 16.2.1 and Clang
> 22.1.8. No failures.
Please give example(s) of such "wide strings" in the changelog.
> Fixes: 0d83da43b1e1 ("objtool/klp: Add --checksum option to generate per-function checksums")
> Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
> Fixes: 873a2208ea31 ("objtool/klp: Calculate object checksums")
> Assisted-by: LLM
> Signed-off-by: Longjun Luo <luolongjuna@gmail.com>
> ---
> tools/objtool/elf.c | 29 +++++++++
> tools/objtool/include/objtool/elf.h | 1 +
> tools/objtool/klp-checksum.c | 44 ++++++++-----
> tools/objtool/klp-diff.c | 14 ++--
> .../tests/generic/fixtures/identity/common.h | 15 +++++
> .../generic/fixtures/identity/wide_string.c | 36 ++++++++++
> .../generic/test-checksum-wide-string.sh | 39 +++++++++++
> tools/objtool/tests/identity-lib.sh | 65 +++++++++++++++++++
> 8 files changed, 223 insertions(+), 20 deletions(-)
> create mode 100644 tools/objtool/tests/generic/fixtures/identity/common.h
> create mode 100644 tools/objtool/tests/generic/fixtures/identity/wide_string.c
> create mode 100755 tools/objtool/tests/generic/test-checksum-wide-string.sh
> create mode 100644 tools/objtool/tests/identity-lib.sh
>
> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> index a791f4ea6ec1..71f1a272e468 100644
> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -1382,6 +1382,35 @@ struct elf *elf_create_file(GElf_Ehdr *ehdr, const char *name)
> return elf;
> }
>
> +/* Wide strings, such as the u16 PSR setup table, end at an all-zero element. */
> +ssize_t elf_string_len(struct section *sec, unsigned long offset)
What is the "u16 PSR setup table"?
> +{
> + size_t entsize = sec->sh.sh_entsize, size, len;
> + const char *str;
> +
> + /*
> + * FIXME: GCC's range_string() uses a one-past-end string pointer.
> + * strlen() reads past the section; preserve the string base and addend.
> + */
> + if (entsize == 1)
> + return strlen(sec->data->d_buf + offset);
I don't understand what this comment means either. Please make sure all
comments and changelogs are written by humans, as LLMs tend to write
nonsensically.
--
Josh
next prev parent reply other threads:[~2026-11-13 2:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 13:31 [RFC PATCH v2 00/11] objtool/klp: DWARF-based cross-build symbol correlation Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 01/11] objtool/klp: Fix checksums and copying of wide strings Longjun Luo
2026-11-13 2:42 ` Josh Poimboeuf [this message]
2026-11-13 4:32 ` Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 02/11] objtool/klp: Hash compound literals by content Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 03/11] objtool/klp: Preserve identifier digits when stripping suffixes Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 04/11] objtool/klp: Read symbol identities from DWARF Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 05/11] objtool/klp: Support reduced and split DWARF Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 06/11] klp-build: Require CONFIG_DEBUG_INFO Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 07/11] objtool/klp: Correlate symbols using DWARF identities Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 08/11] objtool/klp: Include symbol identities in reference checksums Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 09/11] objtool/klp: Extend twins through unchanged function references Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 10/11] objtool/klp: Check unmatched data references Longjun Luo
2026-11-04 13:31 ` [RFC PATCH v2 11/11] objtool/klp: Test symbol identity and state preservation Longjun Luo
2026-11-13 2:35 ` [RFC PATCH v2 00/11] objtool/klp: DWARF-based cross-build symbol correlation Josh Poimboeuf
2026-11-13 3:25 ` Longjun Luo
2026-11-13 3:26 ` Josh Poimboeuf
2026-11-13 3:58 ` Longjun Luo
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=avZ3jEbnuVu5Qv2G@jpoimboe \
--to=jpoimboe@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®