From: Nathan Chancellor <nathan@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: Dmitry Kandybka <d.kandybka@gmail.com>,
Nicolas Schier <nsc@kernel.org>,
linux-kbuild@vger.kernel.org
Subject: Re: [PATCH v2] kbuild: Makefile.lib: fix offsets generation with debug info
Date: Sat, 17 Oct 2026 14:41:29 -0700 [thread overview]
Message-ID: <20261017214129.GA404142@ax162> (raw)
In-Reply-To: <sashiko-outbox-174936@kernel.org>
On Fri, Oct 16, 2026 at 09:02:07PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] kbuild: unanchored sed substitutions in sed-offsets can break build
> --
>
> commit 48672ceb9d59753178f125f7c16956dd57252dcd
> Author: Dmitry Kandybka <d.kandybka@gmail.com>
>
> kbuild: Makefile.lib: fix offsets generation with debug info
>
> This commit fixes offset generation when debug information is enabled by
> making the sed pattern matching stricter and adding a BLANK() macro for
> readability. It prevents debug metadata from leaking into generated header
> files and breaking the build.
>
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index 19e96b30a122f..173bc3aa4247f 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -493,9 +493,9 @@ quiet_cmd_zstd22_with_size = ZSTD22 $@
> > # the .ascii directive whereas GCC keeps the <space> as-is.
> > define sed-offsets
> > 's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
> > - /^->/{s:->#\(.*\):/* \1 */:; \
> > - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
> > - s:->::; p;}'
> > + /^->/{s:->#\(.*\):/* \1 */:p; \
> > + s:^->\([[:alnum:]_]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:p; \
> > + s:->BLANK()::p;}'
>
> [Severity: Low]
> Could this unanchored sed substitution break the build under certain
> conditions?
>
> If the kernel is built with debug info (e.g., -ggdb3), the compiler may emit
> .ascii directives containing debug strings from source code. If a string
> literal from an included header starts with -> and contains -># or ->BLANK()
> mid-string (for example, ->foo ->BLANK()), the unanchored sed substitution
> will match mid-string.
>
> Because of the :p flag, wouldn't it print the partially modified pattern space
> (e.g., ->foo ), resulting in invalid C code being written to
> include/generated/asm-offsets.h?
>
> Should the pattern be anchored (e.g., s:^->BLANK()$::p;) to ensure it only
> matches the intended kbuild macros?
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261015210149.78470-1-d.kandybka@gmail.com?part=1
This definitely feels a little contrived but anchoring at the beginning
would avoid this and seems to match the rest of the macro.
s:^->BLANK()::p;}'
--
Cheers,
Nathan
prev parent reply other threads:[~2026-10-17 21:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 10:53 [PATCH] kbuild: Makefile.lib: fix offsets generation with debug info Dmitry Kandybka
2026-10-05 15:07 ` Nathan Chancellor
2026-10-15 21:01 ` [PATCH v2] " Dmitry Kandybka
2026-10-16 21:02 ` sashiko-bot
2026-10-17 21:41 ` Nathan Chancellor [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=20261017214129.GA404142@ax162 \
--to=nathan@kernel.org \
--cc=d.kandybka@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=nsc@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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