Linux Modules
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Huacai Chen <chenhuacai@kernel.org>, Petr Pavlu <petr.pavlu@suse.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	Daniel Gomez <da.gomez@kernel.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	Aaron Tomlin <atomlin@atomlin.com>,
	linux-modules@vger.kernel.org, loongarch@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] module/kallsyms: Filter out local mapping symbols during module load
Date: Wed, 12 Aug 2026 09:34:22 +0800	[thread overview]
Message-ID: <f933e156-1ef2-3abc-ef8f-b2688e78b957@loongson.cn> (raw)
In-Reply-To: <CAAhV-H5qN2=LEbVS+hd5Uohq6OKHgkxEWLg4GNukYFBmjEABHg@mail.gmail.com>

On 2026/8/11 下午10:22, Huacai Chen wrote:
> Hi, Petr,
> 
> On Tue, Aug 11, 2026 at 8:20 PM Petr Pavlu <petr.pavlu@suse.com> wrote:
>>
>> On 8/11/26 9:15 AM, Tiezhu Yang wrote:
>>> The compiler toolchains generate internal local labels on certain
>>> architectures (such as LoongArch) for optimizations and relocations.
>>>
>>> While these local labels are filtered out during runtime lookups in
>>> find_kallsyms_symbol(), they still leak into the permanent symbol
>>> tables of loaded modules, because layout_symtab() and add_kallsyms()
>>> do not check for the mapping symbols during layout generation.
>>>
>>> Consequently, tracing tools like bpftrace resolve identical addresses
>>> into confusing local labels instead of actual clear C function names.
>>>
>>> Fix this by adding is_mapping_symbol() checks directly into the symbol
>>> tracking loops of layout_symtab() and add_kallsyms(). This prevents the
>>> mapping symbols from entering the module's memory symbol arrays at load
>>> time.
>>
>> This optimization looks sensible to me. Kallsyms in vmlinux also
>> normally doesn't include information about local labels (.L<xyz>) and
>> mapping symbols ($a, $d, ...), so it should be ok not to track them in
>> modules either.
>>
>> Note that the patch description mixes up these two symbol categories,
>> presumably because the existing is_mapping_symbol() function conflates
>> them as well.

...

>> It is better to avoid duplicating the same logic in layout_symtab() and
>> add_kallsyms(). The function is_core_symbol() can be renamed to
>> something like is_kept_symbol() and can be solely responsible for
>> deciding what to keep.
> I'm sorry but I think Tiezhu's patch is simpler and cleaner. :)

Hi Petr and Huacai,

Thanks for your feedback! To make the code cleaner, I plan to split the
changes into the following three patches for v3:

1. module/kallsyms: Rename is_mapping_symbol() to is_local_mapping_symbol()
2. module/kallsyms: Refactor current symbol filtering into is_kept_symbol()
3. module/kallsyms: Filter out local and mapping symbols during module load

I will send out the v3 patch series soon.

Thanks,
Tiezhu


      reply	other threads:[~2026-08-12  1:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  7:15 [PATCH v2] module/kallsyms: Filter out local mapping symbols during module load Tiezhu Yang
2026-08-11 12:20 ` Petr Pavlu
2026-08-11 14:22   ` Huacai Chen
2026-08-12  1:34     ` 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=f933e156-1ef2-3abc-ef8f-b2688e78b957@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=atomlin@atomlin.com \
    --cc=chenhuacai@kernel.org \
    --cc=da.gomez@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mcgrof@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=samitolvanen@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