From ffe1545ce8a0a7bb698d5f68cbbdef8f93d1fce6 Mon Sep 17 00:00:00 2001 From: Petr Pavlu Date: Fri, 27 Mar 2026 08:59:00 +0100 Subject: module, arm: force sh_addr=0 for arch-specific sections When linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1]. Force sh_addr=0 for all arm-specific module sections. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33958 [1] Signed-off-by: Petr Pavlu Signed-off-by: Sami Tolvanen --- arch/arm/include/asm/module.lds.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/module.lds.h b/arch/arm/include/asm/module.lds.h index 0e7cb4e314b4..f9ad774b2889 100644 --- a/arch/arm/include/asm/module.lds.h +++ b/arch/arm/include/asm/module.lds.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #ifdef CONFIG_ARM_MODULE_PLTS SECTIONS { - .plt : { BYTE(0) } - .init.plt : { BYTE(0) } + .plt 0 : { BYTE(0) } + .init.plt 0 : { BYTE(0) } } #endif -- cgit v1.2.3 From c5553deb577fe433f770e270fd9582b8325f12d9 Mon Sep 17 00:00:00 2001 From: Petr Pavlu Date: Fri, 27 Mar 2026 08:59:01 +0100 Subject: module, arm64: force sh_addr=0 for arch-specific sections When linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1]. Force sh_addr=0 for all arm64-specific module sections. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33958 [1] Signed-off-by: Petr Pavlu Signed-off-by: Sami Tolvanen --- arch/arm64/include/asm/module.lds.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/module.lds.h b/arch/arm64/include/asm/module.lds.h index fb944b46846d..0b3aacd22c59 100644 --- a/arch/arm64/include/asm/module.lds.h +++ b/arch/arm64/include/asm/module.lds.h @@ -14,7 +14,7 @@ SECTIONS { * directive to force them into a single section and silence the * warning. */ - .text.hot : { *(.text.hot) } + .text.hot 0 : { *(.text.hot) } #endif #ifdef CONFIG_UNWIND_TABLES @@ -22,6 +22,6 @@ SECTIONS { * Currently, we only use unwind info at module load time, so we can * put it into the .init allocation. */ - .init.eh_frame : { *(.eh_frame) } + .init.eh_frame 0 : { *(.eh_frame) } #endif } -- cgit v1.2.3 From 9cb4d4dc82272538de1b7edb6e8cf91597ed00b0 Mon Sep 17 00:00:00 2001 From: Petr Pavlu Date: Fri, 27 Mar 2026 08:59:02 +0100 Subject: module, m68k: force sh_addr=0 for arch-specific sections When linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1]. Force sh_addr=0 for all m68k-specific module sections. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33958 [1] Signed-off-by: Petr Pavlu Signed-off-by: Sami Tolvanen --- arch/m68k/include/asm/module.lds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/m68k/include/asm/module.lds.h b/arch/m68k/include/asm/module.lds.h index fda94fa38243..fcd08689b282 100644 --- a/arch/m68k/include/asm/module.lds.h +++ b/arch/m68k/include/asm/module.lds.h @@ -1,5 +1,5 @@ SECTIONS { - .m68k_fixup : { + .m68k_fixup 0 : { __start_fixup = .; *(.m68k_fixup) __stop_fixup = .; -- cgit v1.2.3 From 04e17ca3f77e1722a5db068fbcd7b93c51656013 Mon Sep 17 00:00:00 2001 From: Petr Pavlu Date: Fri, 27 Mar 2026 08:59:03 +0100 Subject: module, riscv: force sh_addr=0 for arch-specific sections When linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1]. Force sh_addr=0 for all riscv-specific module sections. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33958 [1] Signed-off-by: Petr Pavlu Signed-off-by: Sami Tolvanen --- arch/riscv/include/asm/module.lds.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/riscv/include/asm/module.lds.h b/arch/riscv/include/asm/module.lds.h index 1075beae1ac6..9ced27c8ccb6 100644 --- a/arch/riscv/include/asm/module.lds.h +++ b/arch/riscv/include/asm/module.lds.h @@ -2,8 +2,8 @@ /* Copyright (C) 2017 Andes Technology Corporation */ #ifdef CONFIG_MODULE_SECTIONS SECTIONS { - .plt : { BYTE(0) } - .got : { BYTE(0) } - .got.plt : { BYTE(0) } + .plt 0 : { BYTE(0) } + .got 0 : { BYTE(0) } + .got.plt 0 : { BYTE(0) } } #endif -- cgit v1.2.3 From ac2f40107cf1296955c867dc31b1a1eceb8ec569 Mon Sep 17 00:00:00 2001 From: Andreas Hindborg Date: Mon, 27 Apr 2026 10:11:35 +0200 Subject: rust: module_param: use `pr_warn_once!` for null pointer warning Replace `pr_warn!` and the accompanying TODO with `pr_warn_once!`, now that the macro is available. [ Note: Adarsh Das independently authored an identical patch on the rust-for-linux list, but it missed the modules tree. ] Suggested-by: Adarsh Das Signed-off-by: Andreas Hindborg Reviewed-by: Aaron Tomlin Reviewed-by: Gary Guo Reviewed-by: Daniel Gomez Signed-off-by: Sami Tolvanen --- rust/kernel/module_param.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs index 6a8a7a875643..dd6d663a0a3c 100644 --- a/rust/kernel/module_param.rs +++ b/rust/kernel/module_param.rs @@ -62,8 +62,7 @@ where // NOTE: If we start supporting arguments without values, val _is_ allowed // to be null here. if val.is_null() { - // TODO: Use pr_warn_once available. - crate::pr_warn!("Null pointer passed to `module_param::set_param`"); + crate::pr_warn_once!("Null pointer passed to `module_param::set_param`"); return EINVAL.to_errno(); } -- cgit v1.2.3 From 786d2d84416a9a1c1a47b71a68d679d886284be2 Mon Sep 17 00:00:00 2001 From: Andrii Kuchmenko Date: Mon, 18 May 2026 17:32:33 +0300 Subject: module: decompress: check return value of module_extend_max_pages() module_extend_max_pages() calls kvrealloc() internally and returns -ENOMEM on allocation failure. The return value is never checked. If the initial allocation fails, info->pages remains NULL and info->max_pages remains 0. Subsequent calls to module_get_next_page() will attempt to dynamically grow the array by calling module_extend_max_pages(info, 0) since info->used_pages is 0. This results in kvrealloc(NULL, 0) returning ZERO_SIZE_PTR, which is treated as a success, leading to a dereference of ZERO_SIZE_PTR and a kernel oops. Fix: add the missing error check after module_extend_max_pages() and return immediately on failure. This matches the pattern used by every other kvrealloc() caller in the module loading path. Fixes: b1ae6dc41eaa ("module: add in-kernel support for decompressing") Cc: Dmitry Torokhov Cc: Luis Chamberlain Cc: stable@vger.kernel.org Signed-off-by: Andrii Kuchmenko Reviewed-by: Christophe Leroy (CS GROUP) [Sami: Corrected the analysis in the commit message.] Signed-off-by: Sami Tolvanen --- kernel/module/decompress.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c index 36f52a232a12..cce098671be9 100644 --- a/kernel/module/decompress.c +++ b/kernel/module/decompress.c @@ -307,6 +307,8 @@ int module_decompress(struct load_info *info, const void *buf, size_t size) */ n_pages = DIV_ROUND_UP(size, PAGE_SIZE) * 2; error = module_extend_max_pages(info, n_pages); + if (error) + return error; data_size = MODULE_DECOMPRESS_FN(info, buf, size); if (data_size < 0) { -- cgit v1.2.3 From 36d6b929bb0c7cc1cc742d9b5805537d3b651094 Mon Sep 17 00:00:00 2001 From: Kenny Glowner Date: Thu, 21 May 2026 11:14:05 -0500 Subject: rust: module_param: add missing newline to pr_warn_once Add a trailing newline ('\n') to the pr_warn_once! call in set_param to ensure the kernel ring buffer flushes the message correctly and prevents log line smearing. Signed-off-by: Kenny Glowner Suggested-by: Miguel Ojeda Link: https://github.com/Rust-for-Linux/linux/issues/1139 [Sami: Updated the commit message as we use pr_warn_once now.] Signed-off-by: Sami Tolvanen --- rust/kernel/module_param.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs index dd6d663a0a3c..6541af218390 100644 --- a/rust/kernel/module_param.rs +++ b/rust/kernel/module_param.rs @@ -62,7 +62,7 @@ where // NOTE: If we start supporting arguments without values, val _is_ allowed // to be null here. if val.is_null() { - crate::pr_warn_once!("Null pointer passed to `module_param::set_param`"); + crate::pr_warn_once!("Null pointer passed to `module_param::set_param`\n"); return EINVAL.to_errno(); } -- cgit v1.2.3