The "module_blacklist=" command-line parameter allows administrators to
prevent specific modules from loading by specifying a comma-separated
list of module names. The blacklisted() helper checks candidate modules
against this list using a strict byte-for-byte comparison via memcmp().
However, the kernel build system normalises module names to use
underscores (e.g., "my_module"), whereas administrators and user-space
utilities may use hyphens (e.g., "my-module") interchangeably.
Because of the strict memcmp(), specifying a module name with a hyphen
on the kernel command line (e.g., "module_blacklist=my-module") fails
to match the internal module name ("my_module"). Consequently, the
module is loaded despite having been explicitly blacklisted, defeating
the intended administrative mitigation.
Replace memcmp() with parameqn(), which treats dashes and underscores as
equivalent. This ensures that module names match correctly regardless of
whether hyphens or underscores are supplied, matching standard kernel
parameter and modprobe behaviour.
Fixes: be7de5f91fdc ("modules: Add kernel parameter to blacklist modules")
Reported-by: sashiko-bot <[email protected]>
Cc: [email protected]
Signed-off-by: Aaron Tomlin <[email protected]>
---
kernel/module/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/module/main.c b/kernel/module/main.c
index d0e1e0bd2ad0..2b708c59f0f1 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2942,7 +2942,7 @@ static bool blacklisted(const char *module_name)
for (p = module_blacklist; *p; p += len) {
len = strcspn(p, ",");
- if (strlen(module_name) == len && !memcmp(module_name, p, len))
+ if (strlen(module_name) == len && parameqn(module_name, p, len))
return true;
if (p[len] == ',')
len++;
--
2.55.0