Re: [PATCH v3] module: Extend module_blacklist parameter to built-in modules

Aaron Tomlin <[email protected]>
Newsgroups org.kernel.vger.linux-arch,org.kernel.vger.linux-kernel,org.kernel.vger.linux-modules
Message-ID <amnaa4wr7kmx5abcixwbfldexlhbn5spzfritjn3gxmutnvbdm@kqeaw6fu7c4l>
On Mon, Jul 06, 2026 at 01:03:37AM -0400, Aaron Tomlin wrote:
> Currently, the "module_blacklist=" command-line parameter only applies to
> loadable modules. If a module is built-in, the parameter is silently
> ignored. This patch extends the blacklisting functionality to built-in
> modules by intercepting their initialization routines during early boot.
> 
> To achieve this, we introduce a new ".initcall.modnames" memory section.
> For each built-in module, we use a standard C structure (i.e., struct
> initcall_modname) to map its initcall function pointer to its associated
> KBUILD_MODNAME string.
> 
> During boot, do_one_initcall() cross-references the initcall function
> pointer against this table. If a match is found and the module is
> present in the blacklist, the initcall is skipped.

Hi Arnd, Luis, Petr, Daniel, Sami,

Please ignore. I will send a v4.

Sashiko [1] correctly reported further issues (e.g., CONFIG_MODULES=n)
which have been addressed as follows:

 - Decoupled the module_blacklist parameter parsing and the
   module_is_blacklisted() function from CONFIG_MODULES, moving the
   logic to init/main.c. This ensures the blacklist works for built-in
   modules even on monolithic kernels built without loadable module
   support (CONFIG_MODULES=n)

 - Removed the conditional stub implementation of
   module_is_blacklisted() in module.h and replaced it with a single,
   unconditional declaration outside of the #ifdef CONFIG_MODULES block.
   This prevents compiler warnings about missing prototypes and ensures
   visibility under a monolithic configuration

 - Replaced the initmem_freed state variable and its synchronisation
   logic in kernel_init() with race-free spatial boundary checks using
   is_kernel_text() and is_kernel_inittext() in initcall_get_modname() .

 - Aligned the .initcall_modnames table with relocations by assigning
   .initcall_fn using the __initcall_stub() helper in
   ___define_initcall(). This ensures the lookup matches the actual stub
   pointer passed to do_one_initcall() when
   CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is enabled

 - Updated initcall_get_modname() in main.c to resolve the function
   pointer fn using dereference_function_descriptor(fn) prior to
   checking the .text and .init.text boundaries

[1]: https://sashiko.dev/#/patchset/20260706050337.7613-1-atomlin%40atomlin.com
-- 
Aaron Tomlin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.