Linux Modules
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Petr Pavlu <petr.pavlu@suse.com>
Cc: linux-modules@vger.kernel.org, loongarch@lists.linux.dev,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>
Subject: [PATCH v4 3/3] module/kallsyms: Ignore local labels and mapping symbols during module load
Date: Thu, 20 Aug 2026 20:50:07 +0800	[thread overview]
Message-ID: <20260820125007.22943-4-yangtiezhu@loongson.cn> (raw)
In-Reply-To: <20260820125007.22943-1-yangtiezhu@loongson.cn>

The compiler toolchains may generate local labels and mapping symbols on
certain architectures like LoongArch for optimizations and relocations.

While these local labels and mapping symbols are already ignored during
runtime lookups via find_kallsyms_symbol(), they still leak into kallsyms
for loaded modules because layout_symtab() and add_kallsyms() don't ignore
them during load time.

Consequently, tracing tools like bpftrace (which do not perform internal
filtering, unlike perf) resolve identical addresses into confusing local
labels instead of actual clear C function names.

Fix this by integrating the is_ignored_kernel_symbol() check directly into
is_core_symbol(). This ensures these unneeded symbols are stripped during
module load time, keeping /proc/kallsyms clean and resulting in accurate
call stacks.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
---
 kernel/module/kallsyms.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c
index d75c9f60d360..1ff8ce857d92 100644
--- a/kernel/module/kallsyms.c
+++ b/kernel/module/kallsyms.c
@@ -89,6 +89,9 @@ static bool is_core_symbol(struct module *mod, const struct load_info *info,
 	    !src->st_name)
 		return false;
 
+	if (is_ignored_kernel_symbol(&info->strtab[src->st_name]))
+		return false;
+
 #ifdef CONFIG_KALLSYMS_ALL
 	if (src->st_shndx == info->index.pcpu)
 		return true;
-- 
2.42.0


      parent reply	other threads:[~2026-08-20 12:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 12:50 [PATCH v4 0/3] Ignore local labels and mapping symbols during module load Tiezhu Yang
2026-08-20 12:50 ` [PATCH v4 1/3] module/kallsyms: Rename is_mapping_symbol() to is_ignored_kernel_symbol() Tiezhu Yang
2026-08-24  8:45   ` Huacai Chen
2026-08-25  1:39     ` Tiezhu Yang
2026-09-01 12:30   ` Petr Pavlu
2026-08-20 12:50 ` [PATCH v4 2/3] module/kallsyms: Refactor current symbol filtering into is_core_symbol() Tiezhu Yang
2026-08-20 12:50 ` Tiezhu Yang [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=20260820125007.22943-4-yangtiezhu@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=jpoimboe@kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=petr.pavlu@suse.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