File mit-unsupported-modules.patch of Package module-init-tools

---
 doc/modprobe.conf.sgml |   13 +++++++++++
 doc/modprobe.sgml      |   19 ++++++++++++++++
 modprobe.c             |   56 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+)

--- modprobe.c.orig
+++ modprobe.c
@@ -65,6 +65,9 @@ typedef void (*errfn_t)(const char *fmt,
 /* Do we use syslog or stderr for messages? */
 static int log;
 
+/* Allow loading of unsupported modules? */
+static int allow_unsupported = 1;
+
 static void message(const char *prefix, const char *fmt, va_list *arglist)
 {
 	char *buf, *buf2;
@@ -654,6 +657,23 @@ static void clear_magic(struct module *m
 	}
 }
 
+static int module_supported(void *mod, unsigned long len)
+{
+	const char *p;
+	unsigned long modlen;
+
+	/* Grab from new-style .modinfo section. */
+	for (p = get_section(mod, len, ".modinfo", &modlen);
+	     p;
+	     p = next_string(p, &modlen)) {
+		if (strcmp(p, "supported=yes") == 0 ||
+		    strcmp(p, "supported=external") == 0) {
+			return 1;
+		}
+	}
+	return 0;
+}
+
 struct module_options
 {
 	struct module_options *next;
@@ -924,6 +944,15 @@ static void insmod(struct list_head *lis
 		goto out_unlock;
 	}
 
+	/* Supported? */
+	if (!allow_unsupported && !module_supported(map, len)) {
+		fatal_exit_code = 2;
+		error("module '%s' is unsupported\n"
+		      "Use --allow-unsupported or set allow_unsupported_modules to 1 in\n"
+		      "/etc/modprobe.d/unsupported-modules\n", mod->filename);
+		goto out;
+	}
+
 	/* Rename it? */
 	if (newname)
 		rename_module(mod, map, len, newname);
@@ -1295,6 +1324,18 @@ static int read_config_file(const char *
 				*commands = add_command(underscores(modname),
 							ptr, *commands);
 			}
+		} else if (strcmp(cmd, "allow_unsupported_modules") == 0) {
+			const char *option = strsep_skipspace(&ptr, "\t ");
+			if (!option)
+				grammar(cmd, filename, linenum);
+			else if (strcmp(option, "yes") == 0 ||
+					strcmp(option, "1") == 0)
+				allow_unsupported = 1;
+			else if (strcmp(option, "no") == 0 ||
+					strcmp(option, "0") == 0)
+				allow_unsupported = 0;
+			else
+				grammar(cmd, filename, linenum);
 		} else
 			grammar(cmd, filename, linenum);
 
@@ -1514,6 +1555,7 @@ static struct option options[] = { { "ve
 				   { "first-time", 0, NULL, 3 },
 				   { "use-blacklist", 0, NULL, 'b' },
 				   { "dump-modversions", 0, NULL, 4 },
+				   { "allow-unsupported-modules", 0, NULL, 128 },
 				   { NULL, 0, NULL, 0 } };
 
 #define MODPROBE_DEVFSD_CONF "/etc/modprobe.devfs"
@@ -1552,6 +1594,7 @@ int main(int argc, char *argv[])
 	int first_time = 0;
 	int use_blacklist = 0;
 	int dump_modver = 0;
+	int force_allow_unsupported = 0;
 	unsigned int i, num_modules;
 	char *type = NULL;
 	const char *config = NULL;
@@ -1674,6 +1717,9 @@ int main(int argc, char *argv[])
 		case 4:
 			dump_modver = 1;
 			break;
+		case 128:
+			force_allow_unsupported = 1;
+			break;
 		default:
 			print_usage(argv[0]);
 		}
@@ -1750,6 +1796,16 @@ int main(int argc, char *argv[])
 		/* Returns the resolved alias, options */
 		read_toplevel_config(config, modulearg, 0,
 		     remove, &modoptions, &commands, &aliases, &blacklist);
+		if (force_allow_unsupported)
+			allow_unsupported = 1;
+		/* Be nice to people running non-suse kernels and allow
+		 * unsupported modules */
+		if (!allow_unsupported) {
+			struct stat sb;
+			if (stat("/proc/sys/kernel/", &sb) == 0 &&
+			    stat("/proc/sys/kernel/unsupported", &sb) == -1)
+				allow_unsupported = 1;
+		}
 
 		/* No luck?  Try symbol names, if starts with symbol:. */
 		if (!aliases
--- doc/modprobe.sgml.orig
+++ doc/modprobe.sgml
@@ -430,9 +430,28 @@
 	  </para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term><option>--allow-unsupported-modules</option>
+        </term>
+        <listitem>
+          <para>
+            Load unsupported modules even if disabled in configuration.
+	  </para>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
   <refsect1>
+    <title>RETURN VALUE</title>
+
+    <para>
+      <command>modprobe</command> returns 0 on success, 1 on an unspecified
+      error and 2 if the module is not supported. Use the
+      <option>--allow-unsupported-modules</option> option to force
+      using an unsupported module.
+    </para>
+  </refsect1>
+  <refsect1>
     <title>BACKWARDS COMPATIBILITY</title>
 
     <para>
--- doc/modprobe.conf.sgml.orig
+++ doc/modprobe.conf.sgml
@@ -188,6 +188,19 @@
 	  </para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term>allow_unsupported_modules <replaceable>[0|1]</replaceable>
+        </term>
+	<listitem>
+	  <para>
+            In SUSE kernels, every kernel module has a flag 'supported'. If
+            this flag is not set loading this module will taint your kernel.
+            Setting this option to 0 disables loading of unsupported modules
+            and avoids tainting the kernel. This is typically set in
+            <filename>/etc/modprobe.d/unsupported-modules</filename>.
+	  </para>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
   <refsect1>
openSUSE Build Service is sponsored by