From: sashiko-bot@kernel.org
To: "David Laight" <david.laight.linux@gmail.com>,
"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>
Cc: "Luis Chamberlain" <mcgrof@kernel.org>,
"Andrey Grodzovsky" <andrey.grodzovsky@crowdstrike.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Samuel Wu" <wusamuel@google.com>,
nathan@kernel.org, nsc@kernel.org
Subject: Re: [PATCH v3 next 09/13] kallsyms: Add a kernel parameter to change the kallsyms_markers[] density
Date: Wed, 11 Nov 2026 13:07:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-209043@kernel.org> (raw)
In-Reply-To: <20261111115911.1142000-10-david.laight.linux@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] kallsyms: wrong markers_cnt rounding in write_src() overflows
or leaks heap
--
commit 03c7dad0d75ad1647bb5f932cd21410fa5140c26
Author: David Laight <david.laight.linux@gmail.com>
kallsyms: Add a kernel parameter to change the kallsyms_markers[] density
This commit adds CONFIG_KALLSYMS_MARKER_SHIFT and a --marker-shift option
to scripts/kallsyms so the interval between kallsyms_markers[] entries is
configurable rather than fixed at 256 symbols.
> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
> index 930ec27a53c06..c27aaabccd1b0 100644
> --- a/scripts/kallsyms.c
> +++ b/scripts/kallsyms.c
[ ... ]
> @@ -441,8 +443,8 @@ static void write_src(void)
> stamp("write token table");
>
> /* table of offset markers, that give the offset in the compressed stream
> - * every 256 symbols */
> - markers_cnt = (table_cnt + 255) / 256;
> + * every (1 << marker_shift) (typically 64 or 256) symbols */
> + markers_cnt = (table_cnt + 255) >> marker_shift;
> markers = xmalloc(sizeof(*markers) * markers_cnt);
[Severity: High]
Should markers_cnt round up using (1u << marker_shift) - 1 instead of
255?
The loop below populates markers[i >> marker_shift] up to index
(table_cnt - 1) >> marker_shift. With 255 still hardcoded,
marker_shift > 8 can under-allocate markers[] by one entry, overflowing
the xmalloc() buffer in write_src() and omitting the final entry from
kallsyms_markers[] so that get_symbol_offset() and get_name_address()
read past the end of kallsyms_markers[] at runtime. Conversely,
marker_shift < 8 (including the new default of 6) over-allocates
markers_cnt and writes uninitialized heap memory from xmalloc() into the
generated kallsyms_markers[] table.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111115911.1142000-1-david.laight.linux@gmail.com?part=9
next prev parent reply other threads:[~2026-11-11 13:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 11:58 [PATCH v3 next 00/13] kallsyms: optimise symbol search by name David Laight
2026-11-11 11:58 ` [PATCH v3 next 01/13] scripts/kallsyms: Avoid overrunning on-stack buffer David Laight
2026-11-11 11:59 ` [PATCH v3 next 02/13] scripts/kallsyms: Improve error reporting David Laight
2026-11-11 12:14 ` sashiko-bot
2026-11-11 23:33 ` bot+bpf-ci
2026-11-11 11:59 ` [PATCH v3 next 03/13] scripts/elf-parse: add elf_map_big_endian() helper David Laight
2026-11-11 11:59 ` [PATCH v3 next 04/13] scripts/kallsyms: make use of binary data output optional David Laight
2026-11-11 12:32 ` sashiko-bot
2026-11-11 23:34 ` bot+bpf-ci
2026-11-11 11:59 ` [PATCH v3 next 05/13] kallsyms: Fix selftest startup delay David Laight
2026-11-11 12:36 ` sashiko-bot
2026-11-11 11:59 ` [PATCH v3 next 06/13] kallsyms: Improve selftest test_perf_kallsyms_lookup_name() output David Laight
2026-11-11 23:17 ` bot+bpf-ci
2026-11-11 11:59 ` [PATCH v3 next 07/13] kallsyms: Match compressed tokens on the fly during binary search David Laight
2026-11-11 12:46 ` sashiko-bot
2026-11-11 11:59 ` [PATCH v3 next 08/13] kallsyms: Optimise symbol name search David Laight
2026-11-11 12:59 ` sashiko-bot
2026-11-11 11:59 ` [PATCH v3 next 09/13] kallsyms: Add a kernel parameter to change the kallsyms_markers[] density David Laight
2026-11-11 13:07 ` sashiko-bot [this message]
2026-11-11 23:33 ` bot+bpf-ci
2026-11-11 11:59 ` [PATCH v3 next 10/13] scripts/kallsyms: Keep full expansion of tokens David Laight
2026-11-11 11:59 ` [PATCH v3 next 11/13] scripts/kallsyms: Optimise compress_symbols() David Laight
2026-11-11 11:59 ` [PATCH v3 next 12/13] scripts/kallsyms: Reuse tokens that have no references David Laight
2026-11-11 23:34 ` bot+bpf-ci
2026-11-11 11:59 ` [PATCH v3 next 13/13] scripts/kallsyms: Reuse little-used compression tokens David Laight
2026-11-11 13:37 ` sashiko-bot
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-209043@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=andrey.grodzovsky@crowdstrike.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=david.laight.linux@gmail.com \
--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-reviews@lists.linux.dev \
--cc=wusamuel@google.com \
/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