From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>
Cc: linux-modules@vger.kernel.org
Subject: Re: [PATCH v9 1/4] kallsyms: embed source file:line info in kernel stack traces
Date: Thu, 17 Sep 2026 13:48:25 +0000 [thread overview]
Message-ID: <20260917134826.62D411F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260917133727.428546-2-sashal@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] scripts: division by zero in find_vmlinux_sym() due to missing sh_entsize check
- [Low] scripts: memory leak of dynamically allocated arrays at exit
--
commit 37641e6c997ac852eedac002b430b40b946dc18d
Author: Sasha Levin <sashal@kernel.org>
Subject: kallsyms: embed source file:line info in kernel stack traces
This commit adds CONFIG_KALLSYMS_LINEINFO, which embeds DWARF-derived
address-to-line mappings directly into the kernel image. A new host tool
(scripts/gen_lineinfo) extracts this info from vmlinux using libdw. The
stack traces will then directly print file and line numbers.
> diff --git a/scripts/gen_lineinfo.c b/scripts/gen_lineinfo.c
> new file mode 100644
> --- /dev/null
> +++ b/scripts/gen_lineinfo.c
[ ... ]
> +static unsigned long long find_vmlinux_sym(Elf *elf, const char *name,
> + unsigned long long fallback,
> + bool required)
> +{
> + size_t nsyms, i;
> + Elf_Scn *scn = NULL;
> + GElf_Shdr shdr;
> +
> + while ((scn = elf_nextscn(elf, scn)) != NULL) {
> + Elf_Data *data;
> +
> + if (!gelf_getshdr(scn, &shdr))
> + continue;
> + if (shdr.sh_type != SHT_SYMTAB)
> + continue;
> +
> + data = elf_getdata(scn, NULL);
> + if (!data)
> + continue;
> +
> + nsyms = shdr.sh_size / shdr.sh_entsize;
[Severity: Low]
Can this division cause a crash if a malformed ELF file is encountered?
If the vmlinux ELF file is malformed and contains an SHT_SYMTAB section
where shdr.sh_entsize is zero, this will result in a division by zero and
a SIGFPE crash. Other functions in this file, such as
collect_symbol_starts(), appear to validate !shdr.sh_entsize before
performing this division. Should this loop skip sections with a zero
sh_entsize as well?
[ ... ]
> +int main(int argc, char *argv[])
> +{
[ ... ]
> + /* Cleanup */
> + free(entries);
> + free(sym_starts);
> + free(seq_ends);
> + for (unsigned int i = 0; i < num_files; i++)
> + free(files[i]);
> + free(files);
> +
> + return 0;
> +}
[Severity: Low]
Does this cleanup block miss some dynamically allocated arrays?
The main() function allocates text_starts, asm_spans, and cu_row_seq_end
during execution, but omits freeing them here. While the OS reclaims memory
upon process exit (making the leak relatively harmless for a short-lived
build tool), the presence of a dedicated cleanup block implies an intent to
achieve a clean memory leak check. Could text_starts, asm_spans, and
cu_row_seq_end be added to this cleanup section?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917133727.428546-1-sashal@kernel.org?part=1
next prev parent reply other threads:[~2026-09-17 13:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 13:37 [PATCH v9 0/4] kallsyms: embed source file:line info in kernel stack traces Sasha Levin
2026-09-17 13:37 ` [PATCH v9 1/4] " Sasha Levin
2026-09-17 13:48 ` sashiko-bot [this message]
2026-09-17 13:37 ` [PATCH v9 2/4] kallsyms: extend lineinfo to loadable modules Sasha Levin
2026-09-17 13:46 ` sashiko-bot
2026-09-17 13:37 ` [PATCH v9 3/4] kallsyms: delta-compress lineinfo tables for ~2.7x size reduction Sasha Levin
2026-09-17 13:37 ` [PATCH v9 4/4] kallsyms: add KUnit tests for lineinfo feature Sasha Levin
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=20260917134826.62D411F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=sashal@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;
as well as URLs for NNTP newsgroup(s).