aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRandy Dunlap <rdunlap@xenotime.net>2006-10-02 05:17:02 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 10:57:12 -0400
commit2bc2d61a9638dab670d8361e928d1a5a291173ef (patch)
treef5d4cf9d3bac97f3da0bd5eb03e76797d47070cd /kernel
parenta58cbd7c249f3079dd62d6391a33b9f43f2bfbef (diff)
[PATCH] list module taint flags in Oops/panic
When listing loaded modules during an oops or panic, also list each module's Tainted flags if non-zero (P: Proprietary or F: Forced load only). If a module is did not taint the kernel, it is just listed like usbcore but if it did taint the kernel, it is listed like wizmodem(PF) Example: [ 3260.121718] Unable to handle kernel NULL pointer dereference at 0000000000000000 RIP: [ 3260.121729] [<ffffffff8804c099>] :dump_test:proc_dump_test+0x99/0xc8 [ 3260.121742] PGD fe8d067 PUD 264a6067 PMD 0 [ 3260.121748] Oops: 0002 [1] SMP [ 3260.121753] CPU 1 [ 3260.121756] Modules linked in: dump_test(P) snd_pcm_oss snd_mixer_oss snd_seq snd_seq_device ide_cd generic ohci1394 snd_hda_intel snd_hda_codec snd_pcm snd_timer snd ieee1394 snd_page_alloc piix ide_core arcmsr aic79xx scsi_transport_spi usblp [ 3260.121785] Pid: 5556, comm: bash Tainted: P 2.6.18-git10 #1 [Alternatively, I can look into listing tainted flags with 'lsmod', but that won't help in oopsen/panics so much.] [akpm@osdl.org: cleanup] Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 05625d5dc758..7c77a0a9275c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -851,6 +851,7 @@ static int check_version(Elf_Shdr *sechdrs,
851 printk("%s: no version for \"%s\" found: kernel tainted.\n", 851 printk("%s: no version for \"%s\" found: kernel tainted.\n",
852 mod->name, symname); 852 mod->name, symname);
853 add_taint(TAINT_FORCED_MODULE); 853 add_taint(TAINT_FORCED_MODULE);
854 mod->taints |= TAINT_FORCED_MODULE;
854 } 855 }
855 return 1; 856 return 1;
856} 857}
@@ -1339,6 +1340,7 @@ static void set_license(struct module *mod, const char *license)
1339 printk(KERN_WARNING "%s: module license '%s' taints kernel.\n", 1340 printk(KERN_WARNING "%s: module license '%s' taints kernel.\n",
1340 mod->name, license); 1341 mod->name, license);
1341 add_taint(TAINT_PROPRIETARY_MODULE); 1342 add_taint(TAINT_PROPRIETARY_MODULE);
1343 mod->taints |= TAINT_PROPRIETARY_MODULE;
1342 } 1344 }
1343} 1345}
1344 1346
@@ -1618,6 +1620,7 @@ static struct module *load_module(void __user *umod,
1618 /* This is allowed: modprobe --force will invalidate it. */ 1620 /* This is allowed: modprobe --force will invalidate it. */
1619 if (!modmagic) { 1621 if (!modmagic) {
1620 add_taint(TAINT_FORCED_MODULE); 1622 add_taint(TAINT_FORCED_MODULE);
1623 mod->taints |= TAINT_FORCED_MODULE;
1621 printk(KERN_WARNING "%s: no version magic, tainting kernel.\n", 1624 printk(KERN_WARNING "%s: no version magic, tainting kernel.\n",
1622 mod->name); 1625 mod->name);
1623 } else if (!same_magic(modmagic, vermagic)) { 1626 } else if (!same_magic(modmagic, vermagic)) {
@@ -1711,10 +1714,14 @@ static struct module *load_module(void __user *umod,
1711 /* Set up license info based on the info section */ 1714 /* Set up license info based on the info section */
1712 set_license(mod, get_modinfo(sechdrs, infoindex, "license")); 1715 set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
1713 1716
1714 if (strcmp(mod->name, "ndiswrapper") == 0) 1717 if (strcmp(mod->name, "ndiswrapper") == 0) {
1715 add_taint(TAINT_PROPRIETARY_MODULE); 1718 add_taint(TAINT_PROPRIETARY_MODULE);
1716 if (strcmp(mod->name, "driverloader") == 0) 1719 mod->taints |= TAINT_PROPRIETARY_MODULE;
1720 }
1721 if (strcmp(mod->name, "driverloader") == 0) {
1717 add_taint(TAINT_PROPRIETARY_MODULE); 1722 add_taint(TAINT_PROPRIETARY_MODULE);
1723 mod->taints |= TAINT_PROPRIETARY_MODULE;
1724 }
1718 1725
1719 /* Set up MODINFO_ATTR fields */ 1726 /* Set up MODINFO_ATTR fields */
1720 setup_modinfo(mod, sechdrs, infoindex); 1727 setup_modinfo(mod, sechdrs, infoindex);
@@ -1760,6 +1767,7 @@ static struct module *load_module(void __user *umod,
1760 printk(KERN_WARNING "%s: No versions for exported symbols." 1767 printk(KERN_WARNING "%s: No versions for exported symbols."
1761 " Tainting kernel.\n", mod->name); 1768 " Tainting kernel.\n", mod->name);
1762 add_taint(TAINT_FORCED_MODULE); 1769 add_taint(TAINT_FORCED_MODULE);
1770 mod->taints |= TAINT_FORCED_MODULE;
1763 } 1771 }
1764#endif 1772#endif
1765 1773
@@ -2226,14 +2234,37 @@ struct module *module_text_address(unsigned long addr)
2226 return mod; 2234 return mod;
2227} 2235}
2228 2236
2237static char *taint_flags(unsigned int taints, char *buf)
2238{
2239 *buf = '\0';
2240 if (taints) {
2241 int bx;
2242
2243 buf[0] = '(';
2244 bx = 1;
2245 if (taints & TAINT_PROPRIETARY_MODULE)
2246 buf[bx++] = 'P';
2247 if (taints & TAINT_FORCED_MODULE)
2248 buf[bx++] = 'F';
2249 /*
2250 * TAINT_FORCED_RMMOD: could be added.
2251 * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
2252 * apply to modules.
2253 */
2254 buf[bx] = ')';
2255 }
2256 return buf;
2257}
2258
2229/* Don't grab lock, we're oopsing. */ 2259/* Don't grab lock, we're oopsing. */
2230void print_modules(void) 2260void print_modules(void)
2231{ 2261{
2232 struct module *mod; 2262 struct module *mod;
2263 char buf[8];
2233 2264
2234 printk("Modules linked in:"); 2265 printk("Modules linked in:");
2235 list_for_each_entry(mod, &modules, list) 2266 list_for_each_entry(mod, &modules, list)
2236 printk(" %s", mod->name); 2267 printk(" %s%s", mod->name, taint_flags(mod->taints, buf));
2237 printk("\n"); 2268 printk("\n");
2238} 2269}
2239 2270