From: Aaron Tomlin <atomlin@atomlin.com>
To: arnd@arndb.de, mcgrof@kernel.org, petr.pavlu@suse.com,
da.gomez@kernel.org, samitolvanen@google.com,
peterz@infradead.org
Cc: akpm@linux-foundation.org, mhiramat@kernel.org,
atomlin@atomlin.com, neelx@suse.com, da.anzani@gmail.com,
sean@ashe.io, chjohnst@mail.com, steve@abita.co,
mproche@mail.com, nick.lane@mail.com, linux-arch@vger.kernel.org,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 0/2] module: Extend blacklist parameter to support built-in modules
Date: Sat, 18 Jul 2026 15:01:19 -0400 [thread overview]
Message-ID: <20260718190121.378314-1-atomlin@atomlin.com> (raw)
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 series extends the blacklisting functionality to
built-in modules by intercepting their initialisation routines during early
boot.
Following review feedback, the implementation has been split into two
separate changes to decouple the introduction of the new feature from the
terminology renaming:
1. The first patch extends the "module_blacklist=" parameter to
built-in modules using the original blacklist terminology. It
introduces the ".initcall.modnames" section to map initcall
function pointers to their associated KBUILD_MODNAME strings
(restricted only to module_init() invocations to save memory and
avoid matching core kernel subsystems). It also restricts the check
to a boot-time __init wrapper to eliminate Use-After-Free (UAF) and
Spectre v1 vulnerability risks when loading dynamic modules at
runtime, and adds a fast-path check to eliminate lookup overhead
when the parameter is not in use
2. The second patch renames the variables and helper functions to
adopt the preferred "module_denylist=" and module_is_denylisted()
terminology in the codebase. To preserve the existing user-space
ABI, "module_blacklist=" is kept as a legacy alias pointing to the
same module_denylist variable
Changes since v5:
- Resolved a modpost cross-section mismatch warning by introducing
do_one_initcall_builtin() as a strict __init wrapper function, rather
than performing the built-in module checks inside the __init_or_module
do_one_initcall() function
- Addressed a UAF race condition with concurrent dynamic module loading by
strictly bounding the blacklist evaluation to early boot via the new
__init wrapper, removing temporal check
- Mitigated a potential Spectre v1 speculative execution vulnerability by
ensuring get_builtin_modname() is exclusively called by __init code,
preventing unprivileged runtime module loading from speculatively
jumping into reclaimed ".init.text" instructions
- Updated Documentation/admin-guide/kernel-parameters.txt to explicitly
mark "module_blacklist=" as deprecated and document "module_denylist="
- Linked to v5: https://lore.kernel.org/lkml/20260718051350.344772-1-atomlin@atomlin.com/
Changes since v4:
- Split the monolithic patch into two distinct commits. One to extend the
functionality to built-in modules, and a second to safely transition the
internal terminology to "denylist" (Arnd Bergmann)
- Preserved "module_blacklist=" as a legacy core_param alias in the second
commit to ensure backwards compatibility with existing userspace
configurations
- Restricted the population of the ".initcall.modnames" section strictly
to module_init() rather than all ___define_initcall() invocations. This
prevents non-module core initcalls from being redundantly mapped, saving
memory and avoiding false-positive matches (Petr Pavlu)
- Introduced a fast-path evaluation to check if the blacklist/denylist is
actually populated before invoking get_builtin_modname(), avoiding
unnecessary lookups during boot (Petr Pavlu)
- Linked to v4: https://lore.kernel.org/lkml/20260708020007.55728-1-atomlin@atomlin.com/
Changes since v3:
- Renamed the external function prototype and internal helper to
module_is_denylisted(), while updating the backing variable in
main.c to module_denylist. To preserve user-space compatibility
while adopting modern terminology, separate core_param entries have
been introduced, allowing both the preferred module_denylist=
parameter and the legacy module_blacklist= parameter to resolve to
the same underlying variable (Andrew Morton)
- I introduced the __initcall_fn_ptr() macro helper to dynamically
resolve the initcall pointer configuration:
- For architectures with relative 32-bit relocations
(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS=y), it resolves to the
relocation stub pointer __initcall_stub(fn, __iid, id)
- For architectures without PREL32 relocations, it resolves
directly to the function pointer fn
- Decoupled the module_denylist parameter parsing and the
module_is_denylisted() function from CONFIG_MODULES, moving the
logic to init/main.c. This ensures the denylist 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_denylisted() 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. Passed the preprocessor
__iid argument to ____define_initcall_modname once to avoid double
evaluation of __COUNTER__ (which caused build failures with LTO)
- 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, and dereference both
fn and p->initcall_fn in the comparison loop to support descriptor-based
architectures (e.g., PPC64)
- Linked to v3: https://lore.kernel.org/lkml/20260706050337.7613-1-atomlin@atomlin.com/
Changes since v2:
- Avoided relative 32-bit offsets (PREL32) with inline assembly, opting
instead for standard C structures with absolute pointers. This fixes LTO
and CFI compatibility issues (e.g., under Clang) where raw inline assembly
fails to track compiler-generated symbols and CFI stubs
- Placed module name strings into the ".init.rodata" section via a dedicated
static array to ensure they are freed from memory after boot
- Avoided Use-After-Free (UAF) bugs post-boot when loading dynamic modules:
- Added an 'initmem_freed' flag, marked as '__ro_after_init', set after
free_initmem() to skip table lookups for dynamically loaded modules
- Added a blacklist check in do_init_module() for dynamic modules
- Simplified the linker script using the BOUNDED_SECTION_PRE_LABEL() macro
to define the ".initcall.modnames" section boundary
- Added a dummy/stub implementation of module_is_blacklisted() when
CONFIG_MODULES is disabled to avoid build errors
- Linked to v2: https://lore.kernel.org/lkml/20260622140259.2974-1-atomlin@atomlin.com/
Changes since v1:
- Pivoted entirely from exposing built-in initcalls and their blacklist
status via a debugfs interface to directly extending the existing
"module_blacklist=" and new "module_blacklist=" to intercept built-in
modules at boot (Petr Pavlu)
- Implemented 32-bit relative offsets (CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)
to store the mappings, preventing binary bloat and preserving KASLR
efficacy
- Linked to v1: https://lore.kernel.org/lkml/20260510061301.41341-1-atomlin@atomlin.com/
Aaron Tomlin (2):
module: Extend module_blacklist parameter to built-in modules
module: Rename module_blacklist to module_denylist
.../admin-guide/kernel-parameters.txt | 6 +-
include/asm-generic/vmlinux.lds.h | 4 +-
include/linux/init.h | 23 +++++++-
include/linux/module.h | 5 +-
init/main.c | 56 ++++++++++++++++++-
kernel/module/main.c | 23 +-------
6 files changed, 90 insertions(+), 27 deletions(-)
--
2.54.0
next reply other threads:[~2026-07-18 19:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 19:01 Aaron Tomlin [this message]
2026-07-18 19:01 ` [PATCH v6 1/2] module: Extend module_blacklist parameter to built-in modules Aaron Tomlin
2026-07-18 19:01 ` [PATCH v6 2/2] module: Rename module_blacklist to module_denylist Aaron Tomlin
2026-07-18 19:11 ` sashiko-bot
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=20260718190121.378314-1-atomlin@atomlin.com \
--to=atomlin@atomlin.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=chjohnst@mail.com \
--cc=da.anzani@gmail.com \
--cc=da.gomez@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mproche@mail.com \
--cc=neelx@suse.com \
--cc=nick.lane@mail.com \
--cc=peterz@infradead.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
--cc=sean@ashe.io \
--cc=steve@abita.co \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.