[PATCH] Blacklist binary-only modules lying about their license

Carl-Daniel Hailfinger
2004-04-27T02:11:21Z

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

Hi,

LinuxAnt offers binary only modules without any sources. To circumvent our
MODULE_LICENSE checks LinuxAnt has inserted a "\0" into their declaration:

MODULE_LICENSE("GPL\0for files in the \"GPL\" directory; for others, only
LICENSE file applies");

Since string comparisons stop at the first "\0" character, the kernel is
tricked into thinking the modules are GPL. Btw, the "GPL" directory they
are speaking about is empty.

The attached patch blacklists all modules having "Linuxant" or "Conexant"
in their author string. This may seem a bit broad, but AFAIK both
companies never have released anything under the GPL and have a strong
history of binary-only modules.

Regards,
Carl-Daniel
--
http://www.hailfinger.org/

[-- Attachment #2: module_blacklist.diff --]
[-- Type: text/plain, Size: 1808 bytes --]

--- linux-2.6.5/kernel/module.c~ 2004-04-04 05:37:37.000000000 +0200
+++ linux-2.6.5/kernel/module.c 2004-04-27 01:24:14.000000000 +0200
@@ -34,6 +34,7 @@
#include <linux/vermagic.h>
#include <linux/notifier.h>
#include <linux/stop_machine.h>
+#include <linux/string.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
#include <asm/pgalloc.h>
@@ -1112,6 +1113,14 @@
}
}

+static inline int license_author_is_not_blacklisted(const char *author)
+{
+ /* LinuxAnt is known to ship non-GPL modules with license=="GPL"
+ to cheat on our checks. Stop them from doing that. */
+ return !(strstr(author, "Linuxant")
+ || strstr(author, "Conexant"));
+}
+
static inline int license_is_gpl_compatible(const char *license)
{
return (strcmp(license, "GPL") == 0
@@ -1121,12 +1130,16 @@
|| strcmp(license, "Dual MPL/GPL") == 0);
}

-static void set_license(struct module *mod, const char *license)
+static void set_license(struct module *mod, const char *license,
+ const char *author)
{
if (!license)
license = "unspecified";
+ if (!author)
+ author = "unspecified";

- mod->license_gplok = license_is_gpl_compatible(license);
+ mod->license_gplok = license_is_gpl_compatible(license)
+ && license_author_is_not_blacklisted(author);
if (!mod->license_gplok) {
printk(KERN_WARNING "%s: module license '%s' taints kernel.\n",
mod->name, license);
@@ -1466,7 +1479,8 @@
module_unload_init(mod);

/* Set up license info based on the info section */
- set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
+ set_license(mod, get_modinfo(sechdrs, infoindex, "license"),
+ get_modinfo(sechdrs, infoindex, "author"));

/* Fix up syms, so that st_value is a pointer to location. */
err = simplify_symbols(sechdrs, symindex, strtab, versindex, pcpuindex,