From: David Laight <david.laight.linux@gmail.com>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev,
"Andrew Morton" <akpm@linux-foundation.org>,
"Petr Mladek" <pmladek@suse.com>, "Kees Cook" <kees@kernel.org>,
linux-kbuild@vger.kernel.org, bpf@vger.kernel.org,
"Jim Cromie" <jim.cromie@gmail.com>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Andrey Grodzovsky" <andrey.grodzovsky@crowdstrike.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
nathan@kernel.org, nsc@kernel.org
Subject: Re: [PATCH v2 next 06/15] kallsyms: Optimise symbol name search
Date: Sun, 18 Oct 2026 18:04:17 +0100 [thread overview]
Message-ID: <20261018180417.5438751b@pumpkin> (raw)
In-Reply-To: <sashiko-outbox-176273@kernel.org>
On Sun, 18 Oct 2026 16:15:56 +0000
sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] kallsyms: race in set_kallsyms_off_size() causes NULL dereference
> - [High] kallsyms: set_kallsyms_off_size() sleeps in atomic context
> --
>
> commit d36232e927821c82911022ce5bae7cb3de465edd
> Author: David Laight <david.laight.linux@gmail.com>
>
> kallsyms: Optimise symbol name search
>
> This commit optimizes symbol name lookups by indexing the compressed
> names table directly instead of the array of symbol values. It supports
> both 24-bit and 32-bit offset tables, selecting between them using a
> static branch initialized on the first symbol lookup.
>
> > diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> > index d18d78e626db2..31451feac8221 100644
> > --- a/kernel/kallsyms.c
> > +++ b/kernel/kallsyms.c
>
> [ ... ]
>
> > @@ -185,14 +216,19 @@ unsigned long kallsyms_sym_address(int idx)
> > return (unsigned long)offset_to_ptr(kallsyms_offsets + idx);
> > }
> >
> > -static unsigned int get_symbol_seq(int index)
> > -{
> > - unsigned int i, seq = 0;
> > +static DEFINE_STATIC_KEY_TRUE(kallsyms_off_size_24);
> >
> > - for (i = 0; i < 3; i++)
> > - seq = (seq << 8) | kallsyms_seqs_of_names[3 * index + i];
> > +static inline unsigned int get_symbol_name_offset(unsigned long index)
> > +{
> > + if (static_branch_likely(&kallsyms_off_size_24))
> > + return kallsyms_off24_of_names[index].v;
> > + return kallsyms_off32_of_names[index];
> > +}
> >
> > - return seq;
> > +static void set_kallsyms_off_size(void)
> > +{
> > + if (kallsyms_off_size != 24)
> > + static_branch_disable(&kallsyms_off_size_24);
> > }
>
> [Severity: High]
> Can calling static_branch_disable() in set_kallsyms_off_size() sleep in
> an atomic or early-boot context when kallsyms_off_size != 24?
Any suggestions on how to get the static branch set early enough?
...
>
> [Severity: High]
> Does DO_ONCE_LITE(set_kallsyms_off_size) allow a concurrent caller to
> dereference NULL in get_symbol_name_offset() when kallsyms_off_size == 32?
I should have just open-code the 'do once'.
It doesn't matter if it is called twice.
But it looks as though I can't patch the code from there anyway.
David
next prev parent reply other threads:[~2026-10-18 17:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 15:51 [PATCH v2 next 00/15] kallsyms: optimise symbol search by name David Laight
2026-10-18 15:51 ` [PATCH v2 next 01/15] kallsyms: scripts/kallsyms.c: Avoid overrunning on-stack buffer David Laight
2026-10-18 15:51 ` [PATCH v2 next 02/15] kallsyms: Fix selftest startup delay David Laight
2026-10-18 15:51 ` [PATCH v2 next 03/15] kallsyms: Improve selftest test_perf_kallsyms_lookup_name() output David Laight
2026-10-18 16:03 ` sashiko-bot
2026-10-18 15:51 ` [PATCH v2 next 04/15] kallsyms: scripts/kallsyms: Check for output file write errors David Laight
2026-10-18 15:51 ` [PATCH v2 next 05/15] kallsyms: Match compressed tokens on the fly during binary search David Laight
2026-10-18 15:51 ` [PATCH v2 next 06/15] kallsyms: Optimise symbol name search David Laight
2026-10-18 16:15 ` sashiko-bot
2026-10-18 17:04 ` David Laight [this message]
2026-10-18 15:51 ` [PATCH v2 next 07/15] kallsyms: Optimise detection of duplicate symbol names David Laight
2026-10-18 15:51 ` [PATCH v2 next 08/15] kallsyms: Support changing the density of the kallsyms_markers[] array David Laight
2026-10-18 15:52 ` [PATCH v2 next 09/15] kallsyms: Add a kernel parameter for the marker shift David Laight
2026-10-18 15:52 ` [PATCH v2 next 10/15] kallsyms: scripts/kallsyms: Rename some variables for clarity David Laight
2026-10-18 15:52 ` [PATCH v2 next 11/15] kallsyms: scripts/kallsyms: Keep full expansion of tokens David Laight
2026-10-18 16:00 ` sashiko-bot
2026-10-18 16:37 ` David Laight
2026-10-18 15:52 ` [PATCH v2 next 12/15] kallsyms: scripts/kallsyms: Optimise compress_symbols() David Laight
2026-10-18 15:52 ` [PATCH v2 next 13/15] kallsyms: scripts/kallsyms: Reuse tokens that have no references David Laight
2026-10-18 15:52 ` [PATCH 14/15] kallsyms: scripts/kallsyms: Reduce the output file size David Laight
2026-10-18 16:05 ` sashiko-bot
2026-10-18 16:47 ` David Laight
2026-10-18 15:52 ` [PATCH 15/15] kallsyms: scripts/kallsyms: Improve compression by about 2% David Laight
2026-10-18 16:05 ` sashiko-bot
2026-10-18 17:28 ` David Laight
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=20261018180417.5438751b@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andrey.grodzovsky@crowdstrike.com \
--cc=bpf@vger.kernel.org \
--cc=jim.cromie@gmail.com \
--cc=kees@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=mcgrof@kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sashiko-bot@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 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.