Linux Modules
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Luis Chamberlain <mcgrof@kernel.org>,
	Petr Pavlu <petr.pavlu@suse.com>,
	Daniel Gomez <da.gomez@kernel.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	Aaron Tomlin <atomlin@atomlin.com>
Cc: linux-modules@vger.kernel.org, loongarch@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] module/kallsyms: Filter out local mapping symbols during module load
Date: Mon, 10 Aug 2026 10:06:47 +0800	[thread overview]
Message-ID: <71fe6152-65f8-cf30-08d0-004c2a7d922a@loongson.cn> (raw)
In-Reply-To: <20260808033715.13117-1-yangtiezhu@loongson.cn>

On 2026/8/8 上午11:37, Tiezhu Yang wrote:
> The compiler toolchains generate internal local labels on certain
> architectures (such as LoongArch) for optimizations and relocations.

...

> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> Based on the latest modules-next branch of
> https://git.kernel.org/pub/scm/linux/kernel/git/modules/linux.git
> 
>   kernel/module/kallsyms.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c
> index f23126d804b2..61dd5c014a59 100644
> --- a/kernel/module/kallsyms.c
> +++ b/kernel/module/kallsyms.c
> @@ -130,6 +130,9 @@ void layout_symtab(struct module *mod, struct load_info *info)
>   
>   	/* Compute total space required for the core symbols' strtab. */
>   	for (ndst = i = 0; i < nsrc; i++) {
> +		if (is_mapping_symbol(&info->strtab[src[i].st_name]))
> +			continue;
> +
>   		if (i == 0 || is_livepatch_module(mod) ||
>   		    is_core_symbol(src + i, info->sechdrs, info->hdr->e_shnum,
>   				   info->index.pcpu)) {
> @@ -198,6 +201,10 @@ void add_kallsyms(struct module *mod, const struct load_info *info)
>   	src = kallsyms->symtab;
>   	for (ndst = i = 0; i < kallsyms->num_symtab; i++) {
>   		kallsyms->typetab[i] = elf_type(src + i, info);
> +
> +		if (is_mapping_symbol(&kallsyms->strtab[src[i].st_name]))
> +			continue;
> +
>   		if (i == 0 || is_livepatch_module(mod) ||
>   		    is_core_symbol(src + i, info->sechdrs, info->hdr->e_shnum,
>   				   info->index.pcpu)) {
> 

Hi module maintainers,

Regarding the feedback from the AI bot about livepatch breaking [1],
there are two ways to fix it, which style do you prefer?

(1) Using continue

```
diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c
index f23126d804b2..aece7aa49dd4 100644
--- a/kernel/module/kallsyms.c
+++ b/kernel/module/kallsyms.c
@@ -130,6 +130,10 @@ void layout_symtab(struct module *mod, struct 
load_info *info)

         /* Compute total space required for the core symbols' strtab. */
         for (ndst = i = 0; i < nsrc; i++) {
+               if (!is_livepatch_module(mod) &&
+                   is_mapping_symbol(&info->strtab[src[i].st_name]))
+                       continue;
+
                 if (i == 0 || is_livepatch_module(mod) ||
                     is_core_symbol(src + i, info->sechdrs, 
info->hdr->e_shnum,
                                    info->index.pcpu)) {
@@ -198,6 +202,11 @@ void add_kallsyms(struct module *mod, const struct 
load_info *info)
         src = kallsyms->symtab;
         for (ndst = i = 0; i < kallsyms->num_symtab; i++) {
                 kallsyms->typetab[i] = elf_type(src + i, info);
+
+               if (!is_livepatch_module(mod) &&
+                   is_mapping_symbol(&kallsyms->strtab[src[i].st_name]))
+                       continue;
+
                 if (i == 0 || is_livepatch_module(mod) ||
                     is_core_symbol(src + i, info->sechdrs, 
info->hdr->e_shnum,
                                    info->index.pcpu)) {
```

(2) Using if-statement
```
diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c
index f23126d804b2..b2b22b3487a8 100644
--- a/kernel/module/kallsyms.c
+++ b/kernel/module/kallsyms.c
@@ -130,9 +130,12 @@ void layout_symtab(struct module *mod, struct 
load_info *info)

         /* Compute total space required for the core symbols' strtab. */
         for (ndst = i = 0; i < nsrc; i++) {
-               if (i == 0 || is_livepatch_module(mod) ||
+               bool is_mapping = !is_livepatch_module(mod) &&
+ 
is_mapping_symbol(&info->strtab[src[i].st_name]);
+
+               if (!is_mapping && (i == 0 || is_livepatch_module(mod) ||
                     is_core_symbol(src + i, info->sechdrs, 
info->hdr->e_shnum,
-                                  info->index.pcpu)) {
+                                  info->index.pcpu))) {
                         strtab_size += 
strlen(&info->strtab[src[i].st_name]) + 1;
                         ndst++;
                 }
@@ -198,9 +201,13 @@ void add_kallsyms(struct module *mod, const struct 
load_info *info)
         src = kallsyms->symtab;
         for (ndst = i = 0; i < kallsyms->num_symtab; i++) {
                 kallsyms->typetab[i] = elf_type(src + i, info);
-               if (i == 0 || is_livepatch_module(mod) ||
+
+               bool is_mapping = !is_livepatch_module(mod) &&
+ 
is_mapping_symbol(&kallsyms->strtab[src[i].st_name]);
+
+               if (!is_mapping && (i == 0 || is_livepatch_module(mod) ||
                     is_core_symbol(src + i, info->sechdrs, 
info->hdr->e_shnum,
-                                  info->index.pcpu)) {
+                                  info->index.pcpu))) {
                         ssize_t ret;

                         mod->core_kallsyms.typetab[ndst] =
```

If you have any more comments, please let me know.

[1] 
https://lore.kernel.org/linux-modules/20260808035301.C3E6F1F000E9@smtp.kernel.org/

Thanks,
Tiezhu


  parent reply	other threads:[~2026-08-10  2:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08  3:37 [PATCH v1] module/kallsyms: Filter out local mapping symbols during module load Tiezhu Yang
2026-08-08  3:53 ` sashiko-bot
2026-08-10  2:06 ` Tiezhu Yang [this message]
2026-08-10  3:55   ` 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=71fe6152-65f8-cf30-08d0-004c2a7d922a@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=atomlin@atomlin.com \
    --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