aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorAndi Kleen <andi@firstfloor.org>2008-10-16 01:01:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:31 -0400
commit25ddbb18aae33ad255eb9f35aacebe3af01e1e9c (patch)
tree8df1f840a226ed640c2096710b7d0f1f4d1b88aa /kernel/module.c
parent889d51a10712b6fd6175196626de2116858394f4 (diff)
Make the taint flags reliable
It's somewhat unlikely that it happens, but right now a race window between interrupts or machine checks or oopses could corrupt the tainted bitmap because it is modified in a non atomic fashion. Convert the taint variable to an unsigned long and use only atomic bit operations on it. Unfortunately this means the intvec sysctl functions cannot be used on it anymore. It turned out the taint sysctl handler could actually be simplified a bit (since it only increases capabilities) so this patch actually removes code. [akpm@linux-foundation.org: remove unneeded include] Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 9db11911e04b..dd9ac6ad5cb9 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -100,7 +100,7 @@ static inline int strong_try_module_get(struct module *mod)
100static inline void add_taint_module(struct module *mod, unsigned flag) 100static inline void add_taint_module(struct module *mod, unsigned flag)
101{ 101{
102 add_taint(flag); 102 add_taint(flag);
103 mod->taints |= flag; 103 mod->taints |= (1U << flag);
104} 104}
105 105
106/* 106/*
@@ -923,7 +923,7 @@ static const char vermagic[] = VERMAGIC_STRING;
923static int try_to_force_load(struct module *mod, const char *symname) 923static int try_to_force_load(struct module *mod, const char *symname)
924{ 924{
925#ifdef CONFIG_MODULE_FORCE_LOAD 925#ifdef CONFIG_MODULE_FORCE_LOAD
926 if (!(tainted & TAINT_FORCED_MODULE)) 926 if (!test_taint(TAINT_FORCED_MODULE))
927 printk("%s: no version for \"%s\" found: kernel tainted.\n", 927 printk("%s: no version for \"%s\" found: kernel tainted.\n",
928 mod->name, symname); 928 mod->name, symname);
929 add_taint_module(mod, TAINT_FORCED_MODULE); 929 add_taint_module(mod, TAINT_FORCED_MODULE);
@@ -1033,7 +1033,7 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
1033 const unsigned long *crc; 1033 const unsigned long *crc;
1034 1034
1035 ret = find_symbol(name, &owner, &crc, 1035 ret = find_symbol(name, &owner, &crc,
1036 !(mod->taints & TAINT_PROPRIETARY_MODULE), true); 1036 !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true);
1037 if (!IS_ERR_VALUE(ret)) { 1037 if (!IS_ERR_VALUE(ret)) {
1038 /* use_module can fail due to OOM, 1038 /* use_module can fail due to OOM,
1039 or module initialization or unloading */ 1039 or module initialization or unloading */
@@ -1634,7 +1634,7 @@ static void set_license(struct module *mod, const char *license)
1634 license = "unspecified"; 1634 license = "unspecified";
1635 1635
1636 if (!license_is_gpl_compatible(license)) { 1636 if (!license_is_gpl_compatible(license)) {
1637 if (!(tainted & TAINT_PROPRIETARY_MODULE)) 1637 if (!test_taint(TAINT_PROPRIETARY_MODULE))
1638 printk(KERN_WARNING "%s: module license '%s' taints " 1638 printk(KERN_WARNING "%s: module license '%s' taints "
1639 "kernel.\n", mod->name, license); 1639 "kernel.\n", mod->name, license);
1640 add_taint_module(mod, TAINT_PROPRIETARY_MODULE); 1640 add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
@@ -2552,9 +2552,9 @@ static char *module_flags(struct module *mod, char *buf)
2552 mod->state == MODULE_STATE_GOING || 2552 mod->state == MODULE_STATE_GOING ||
2553 mod->state == MODULE_STATE_COMING) { 2553 mod->state == MODULE_STATE_COMING) {
2554 buf[bx++] = '('; 2554 buf[bx++] = '(';
2555 if (mod->taints & TAINT_PROPRIETARY_MODULE) 2555 if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE))
2556 buf[bx++] = 'P'; 2556 buf[bx++] = 'P';
2557 if (mod->taints & TAINT_FORCED_MODULE) 2557 if (mod->taints & (1 << TAINT_FORCED_MODULE))
2558 buf[bx++] = 'F'; 2558 buf[bx++] = 'F';
2559 /* 2559 /*
2560 * TAINT_FORCED_RMMOD: could be added. 2560 * TAINT_FORCED_RMMOD: could be added.