mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: Fri, 13 Nov 2026 10:27:51 -0800	[thread overview]
Message-ID: <avdWaZboJeDyyOMs@jpoimboe> (raw)
In-Reply-To: <CAKL4jwX=ctyjXmm=Oz_+HXe89vOHWHgT_-KGyL47fOBEQTYJiQ@mail.gmail.com>

On Fri, Nov 13, 2026 at 12:32:20PM +0800, Longjun Luo wrote:
> Sorry, I left out the debugging context here. Both comments refer to
> specific kernel build artifacts:
> 
> On Thu, Nov 12, 2026 at 06:42:36PM -0800, Josh Poimboeuf wrote:
> > Please give example(s) of such "wide strings" in the changelog.
> >
> > > +/* 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"?
> 
> PSR stands for Panel Self Refresh.
> 
> Source    : drivers/gpu/drm/display/drm_dp_helper.c: drm_dp_psr_setup_time()
>             /* macros expanded */
>             static const u16 psr_setup_time_us[] = { 330, 275, 220,
> 165, 110, 55, 0 };
> Section   : .rodata.str2.2 (SHF_STRINGS, sh_entsize = 2, Clang ThinLTO)
> Bytes     : 4a 01 13 01 dc 00 a5 00 6e 00 37 00 00 00
>                         ^^^^^
>                         220 (0x00dc) contains a zero byte at offset +5
> 
> objtool   : strlen() returns 5. The checksum hashes only 5 bytes, and
>             the copy includes only 6 of the table's 14 bytes.
> 
> > > + /*
> > > + * 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.
> 
> Source    : lib/vsprintf.c: range_string()
>             p = string_nocheck(p, pend, "[range ", default_str_spec);
> Section   : .rodata.range_string.isra.0.str1.1 (8 bytes: "[range \0")
> Reloc     : range_string.isra.0+0x9a: R_X86_64_32S .LC22+8
> 
> GCC note  : Uses .LC22+8 (one-past-the-end pointer) as a loop bound without
>             dereferencing it.
> objtool   : Passes offset = 8 to strlen(sec->data->d_buf + 8), reading past
>             the 8-byte section. Fixing this requires tracking the base
>             string (.LC22) and the +8 addend separately (left as a FIXME).
> 
> I came across both while testing on full kernel builds rather than in
> production livepatching, so I'll leave it to you whether they are worth
> addressing in practice.

It's probably worth fixing, just the comments and commit log need to be
clear about what exactly we're fixing.

-- 
Josh

  reply	other threads:[~2026-11-13 18:27 UTC|newest]

Thread overview: 20+ 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
2026-11-13  4:32     ` Longjun Luo
2026-11-13 18:27       ` Josh Poimboeuf [this message]
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
2026-11-13 18:34     ` 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=avdWaZboJeDyyOMs@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®