Skip to content

Commit 061b1bd

Browse files
committed
Staging: add TAINT_CRAP for all drivers/staging code
We need to add a flag for all code that is in the drivers/staging/ directory to prevent all other kernel developers from worrying about issues here, and to notify users that the drivers might not be as good as they are normally used to. Based on code from Andreas Gruenbacher and Jeff Mahoney to provide a TAINT flag for the support level of a kernel module in the Novell enterprise kernel release. This is the kernel portion of this feature, the ability for the flag to be set needs to be done in the build process and will happen in a follow-up patch. Cc: Andreas Gruenbacher <agruen@suse.de> Cc: Jeff Mahoney <jeffm@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent b922df7 commit 061b1bd

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎Documentation/sysctl/kernel.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,5 @@ can be ORed together:
369369
2 - A module was force loaded by insmod -f.
370370
Set by modutils >= 2.4.9 and module-init-tools.
371371
4 - Unsafe SMP processors: SMP with CPUs not designed for SMP.
372+
64 - A module from drivers/staging was loaded.
372373

‎include/linux/kernel.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ extern enum system_states {
260260
#define TAINT_DIE (1<<7)
261261
#define TAINT_OVERRIDDEN_ACPI_TABLE (1<<8)
262262
#define TAINT_WARN (1<<9)
263+
#define TAINT_CRAP (1<<10)
263264

264265
extern void dump_stack(void) __cold;
265266

‎kernel/module.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,7 @@ static noinline struct module *load_module(void __user *umod,
18061806
Elf_Ehdr *hdr;
18071807
Elf_Shdr *sechdrs;
18081808
char *secstrings, *args, *modmagic, *strtab = NULL;
1809+
char *staging;
18091810
unsigned int i;
18101811
unsigned int symindex = 0;
18111812
unsigned int strindex = 0;
@@ -1960,6 +1961,14 @@ static noinline struct module *load_module(void __user *umod,
19601961
goto free_hdr;
19611962
}
19621963

1964+
staging = get_modinfo(sechdrs, infoindex, "staging");
1965+
if (staging) {
1966+
add_taint_module(mod, TAINT_CRAP);
1967+
printk(KERN_WARNING "%s: module is from the staging directory,"
1968+
" the quality is unknown, you have been warned.\n",
1969+
mod->name);
1970+
}
1971+
19631972
/* Now copy in args */
19641973
args = strndup_user(uargs, ~0UL >> 1);
19651974
if (IS_ERR(args)) {
@@ -2556,6 +2565,8 @@ static char *module_flags(struct module *mod, char *buf)
25562565
buf[bx++] = 'P';
25572566
if (mod->taints & TAINT_FORCED_MODULE)
25582567
buf[bx++] = 'F';
2568+
if (mod->taints & TAINT_CRAP)
2569+
buf[bx++] = 'C';
25592570
/*
25602571
* TAINT_FORCED_RMMOD: could be added.
25612572
* TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't

‎kernel/panic.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ EXPORT_SYMBOL(panic);
155155
* 'U' - Userspace-defined naughtiness.
156156
* 'A' - ACPI table overridden.
157157
* 'W' - Taint on warning.
158+
* 'C' - modules from drivers/staging are loaded.
158159
*
159160
* The string is overwritten by the next call to print_taint().
160161
*/
@@ -163,7 +164,7 @@ const char *print_tainted(void)
163164
{
164165
static char buf[20];
165166
if (tainted) {
166-
snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c%c",
167+
snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c%c%c",
167168
tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
168169
tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
169170
tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
@@ -173,7 +174,8 @@ const char *print_tainted(void)
173174
tainted & TAINT_USER ? 'U' : ' ',
174175
tainted & TAINT_DIE ? 'D' : ' ',
175176
tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' ',
176-
tainted & TAINT_WARN ? 'W' : ' ');
177+
tainted & TAINT_WARN ? 'W' : ' ',
178+
tainted & TAINT_CRAP ? 'C' : ' ');
177179
}
178180
else
179181
snprintf(buf, sizeof(buf), "Not tainted");

0 commit comments

Comments
 (0)