[PATCH rhel5 3/4] Check blacklist= for the module name before loading it (#569883)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Prevent loader from loading blacklisted modules. Pass blacklist=modname
to the kernel, one module per blacklist= entry.

Related: rhbz#569883
---
 loader2/modules.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/loader2/modules.c b/loader2/modules.c
index 4b59777..b30fb2f 100644
--- a/loader2/modules.c
+++ b/loader2/modules.c
@@ -43,6 +43,10 @@
 /* boot flags */
 extern uint64_t flags;
 
+/* parsed /proc/cmdline */
+extern char **cmdline_argv;
+extern int cmdline_argc;
+
 static int writeModulesConf(moduleList list, char *conf);
 static struct extractedModule * extractModules (char * const * modNames,
                                                 struct extractedModule * oldPaths,
@@ -246,6 +250,18 @@ int mlModuleInList(const char * modName, moduleList list) {
     return 0;
 }
 
+int mlModuleInBlacklist(const char * modName) {
+    int i;
+
+    for (i=0; i < cmdline_argc; i++) {
+        if (!strncasecmp(cmdline_argv[i], "blacklist=", 10))
+            if (!strcmp(cmdline_argv[i][10], modName))
+                return 1;
+    }
+
+    return 0;
+}
+
 static struct loadedModuleInfo * getLoadedModuleInfo(moduleList modLoaded, 
                                                      const char * modName) {
     int i = 0;
@@ -270,7 +286,7 @@ static int loadModule(const char * modName, struct extractedModule * path,
     static int usbWasLoaded = 0;
  
     /* don't need to load a module that's already loaded */
-    if (mlModuleInList(modName, modLoaded))
+    if (mlModuleInList(modName, modLoaded) || mlModuleInBlacklist(start))
         return 0;
 
     if (modInfo && (mi = findModuleInfo(modInfo, modName))) {
@@ -479,7 +495,7 @@ static int doLoadModules(const char * origModNames, moduleList modLoaded,
             next++;
         }
 
-        if (mlModuleInList(start, modLoaded)) {
+        if (mlModuleInList(start, modLoaded) || mlModuleInBlacklist(start)) {
             /* already loaded, we don't need to load it again */
             start = next;
             continue;
-- 
1.7.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux