From: sashiko-bot@kernel.org
To: "Tiezhu Yang" <yangtiezhu@loongson.cn>
Cc: linux-modules@vger.kernel.org
Subject: Re: [PATCH v3 3/3] module/kallsyms: Filter out local and mapping symbols during module load
Date: Wed, 12 Aug 2026 03:44:16 +0000 [thread overview]
Message-ID: <20260812034416.DAB981F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812032807.15034-4-yangtiezhu@loongson.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Relocations can modify `.symtab` and `.strtab` between `layout_symtab()` and `add_kallsyms()`, leading to a heap buffer overflow, out-of-bounds read, and security control bypass.
--
--- Patch [3]: [PATCH v3 3/3] module/kallsyms: Filter out local and mapping symbols during module load ---
commit b99e0a63da9d8d5ffb4bf7cbd78e368abde75865
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
module/kallsyms: Filter out local and mapping symbols during module load
The compiler toolchains generate local and mapping symbols on certain
architectures like LoongArch for optimizations and relocations. This
commit filters them out during module load time using the newly
introduced is_kept_symbol() helper to keep /proc/kallsyms clean.
> diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c
> index efc73f66defd5..77e05b5ca1f2c 100644
> --- a/kernel/module/kallsyms.c
> +++ b/kernel/module/kallsyms.c
> @@ -89,6 +89,9 @@ static bool is_kept_symbol(struct module *mod, const struct load_info *info,
> !src->st_name)
> return false;
>
> + if (is_local_mapping_symbol(&info->strtab[src->st_name]))
> + return false;
> +
[Severity: High]
This is a pre-existing issue, but does this new check introduce an
out-of-bounds read if a malformed module modifies st_name?
In layout_symtab(), .symtab and .strtab are marked with SHF_ALLOC:
kernel/module/kallsyms.c:layout_symtab() {
...
symsect->sh_flags |= SHF_ALLOC;
strsect->sh_flags |= SHF_ALLOC;
...
}
Later, apply_relocations() applies relocations to sections with
SHF_ALLOC, which can mutate the symbol and string tables in module memory:
kernel/module/main.c:apply_relocations() {
...
if (!(info->sechdrs[infosec].sh_flags & SHF_ALLOC) &&
(!infosec || infosec != info->index.pcpu))
continue;
...
}
When add_kallsyms() re-evaluates the mutated symbol table, it calls
is_kept_symbol(), which uses the mutated src->st_name without bounds
checking against the unmodified info->strtab.
Could this read out of bounds if st_name is maliciously inflated?
Also, since a previously rejected symbol might now be kept after mutation,
could this overflow the mod->core_kallsyms.symtab array since the number
of kept symbols might now exceed the pre-calculated allocation?
> #ifdef CONFIG_KALLSYMS_ALL
> if (src->st_shndx == info->index.pcpu)
> return true;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812032807.15034-1-yangtiezhu@loongson.cn?part=3
next prev parent reply other threads:[~2026-08-12 3:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 3:28 [PATCH v3 0/3] Filter out local and mapping symbols during module load Tiezhu Yang
2026-08-12 3:28 ` [PATCH v3 1/3] module/kallsyms: Rename is_mapping_symbol() to is_local_mapping_symbol() Tiezhu Yang
2026-08-12 3:28 ` [PATCH v3 2/3] module/kallsyms: Refactor current symbol filtering into is_kept_symbol() Tiezhu Yang
2026-08-12 3:42 ` sashiko-bot
2026-08-12 3:28 ` [PATCH v3 3/3] module/kallsyms: Filter out local and mapping symbols during module load Tiezhu Yang
2026-08-12 3:44 ` sashiko-bot [this message]
2026-08-12 4:19 ` Tiezhu Yang
2026-08-12 15:17 ` [PATCH v3 0/3] " Huacai Chen
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=20260812034416.DAB981F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yangtiezhu@loongson.cn \
/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.