Messages in this thread Patch in this message | | | Subject | Re: [PATCH] Blacklist binary-only modules lying about their license | From | Rusty Russell <> | Date | Tue, 27 Apr 2004 16:04:06 +1000 |
| |
On Tue, 2004-04-27 at 14:31, Linus Torvalds wrote: > Anyway, I suspect that rather than blacklist bad people, I'd much prefer > to have the module tags be done as counted strings instead. It should be > easy enough to do by just having the macro prepend a "sizeof(xxxx)" > thing or something. > > Hmm. At least with -sdt=c99 it should be trivial, with something like > > #define __MODULE_INFO(tag, name, info) \ > static struct { int len; const char value[] } \ > __module_cat(name,__LINE__) __attribute_used__ \ > __attribute__((section(".modinfo"),unused)) = \ > { sizeof(__stringify(tag) "=" info), \ > __stringify(tag) "=" info } > > doing the job.
Cute, but breaks the "modinfo" tool unfortunately. I'd prefer not to do that. Since they want to circumvent this, almost anything we want to do is a waste of time.
Rusty.
Name: Stop most obvious abuse of MODULE_LICENSE Status: Tested on 2.6.6-rc2-bk4
Arms race forces bloat upon module users.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .31262-linux-2.6.6-rc2-bk4/include/linux/module.h .31262-linux-2.6.6-rc2-bk4.updated/include/linux/module.h --- .31262-linux-2.6.6-rc2-bk4/include/linux/module.h 2004-04-22 08:03:55.000000000 +1000 +++ .31262-linux-2.6.6-rc2-bk4.updated/include/linux/module.h 2004-04-27 15:52:19.000000000 +1000 @@ -16,6 +16,9 @@ #include <linux/kmod.h> #include <linux/elf.h> #include <linux/stringify.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/compiler.h> #include <asm/local.h> #include <asm/module.h> @@ -61,7 +64,14 @@ void sort_main_extable(void); #ifdef MODULE #define ___module_cat(a,b) __mod_ ## a ## b #define __module_cat(a,b) ___module_cat(a,b) +/* Some sick fucks embeded NULs in MODULE_LICENSE to circumvent checks. */ +#define __MODULE_INFO_CHECK(info) \ + static void __init __attribute_used__ \ + __module_cat(__mc_,__LINE__)(void) { \ + BUILD_BUG_ON(__builtin_strlen(info) + 1 != sizeof(info)); \ + } #define __MODULE_INFO(tag, name, info) \ +__MODULE_INFO_CHECK(info); \ static const char __module_cat(name,__LINE__)[] \ __attribute_used__ \ __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
-- Anyone who quotes me in their signature is an idiot -- Rusty Russell
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |