Skip to content

Commit 2449b8b

Browse files
bwhacksrustyrussell
authored andcommitted
module,bug: Add TAINT_OOT_MODULE flag for modules not built in-tree
Use of the GPL or a compatible licence doesn't necessarily make the code any good. We already consider staging modules to be suspect, and this should also be true for out-of-tree modules which may receive very little review. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Reviewed-by: Dave Jones <davej@redhat.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (patched oops-tracing.txt)
1 parent 1cd0d6c commit 2449b8b

5 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎Documentation/oops-tracing.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ characters, each representing a particular tainted value.
263263
12: 'I' if the kernel is working around a severe bug in the platform
264264
firmware (BIOS or similar).
265265

266+
13: 'O' if an externally-built ("out-of-tree") module has been loaded.
267+
266268
The primary reason for the 'Tainted: ' string is to tell kernel
267269
debuggers if this is a clean kernel or if anything unusual has
268270
occurred. Tainting is permanent: even if an offending module is

‎include/linux/kernel.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ extern enum system_states {
371371
#define TAINT_WARN 9
372372
#define TAINT_CRAP 10
373373
#define TAINT_FIRMWARE_WORKAROUND 11
374+
#define TAINT_OOT_MODULE 12
374375

375376
extern const char hex_asc[];
376377
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]

‎kernel/module.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,6 +2487,9 @@ static int check_modinfo(struct module *mod, struct load_info *info)
24872487
return -ENOEXEC;
24882488
}
24892489

2490+
if (!get_modinfo(info, "intree"))
2491+
add_taint_module(mod, TAINT_OOT_MODULE);
2492+
24902493
if (get_modinfo(info, "staging")) {
24912494
add_taint_module(mod, TAINT_CRAP);
24922495
printk(KERN_WARNING "%s: module is from the staging directory,"
@@ -3255,6 +3258,8 @@ static char *module_flags(struct module *mod, char *buf)
32553258
buf[bx++] = '(';
32563259
if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE))
32573260
buf[bx++] = 'P';
3261+
else if (mod->taints & (1 << TAINT_OOT_MODULE))
3262+
buf[bx++] = 'O';
32583263
if (mod->taints & (1 << TAINT_FORCED_MODULE))
32593264
buf[bx++] = 'F';
32603265
if (mod->taints & (1 << TAINT_CRAP))

‎kernel/panic.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ static const struct tnt tnts[] = {
177177
{ TAINT_WARN, 'W', ' ' },
178178
{ TAINT_CRAP, 'C', ' ' },
179179
{ TAINT_FIRMWARE_WORKAROUND, 'I', ' ' },
180+
{ TAINT_OOT_MODULE, 'O', ' ' },
180181
};
181182

182183
/**
@@ -194,6 +195,7 @@ static const struct tnt tnts[] = {
194195
* 'W' - Taint on warning.
195196
* 'C' - modules from drivers/staging are loaded.
196197
* 'I' - Working around severe firmware bug.
198+
* 'O' - Out-of-tree module has been loaded.
197199
*
198200
* The string is overwritten by the next call to print_tainted().
199201
*/

‎scripts/mod/modpost.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,12 @@ static void add_header(struct buffer *b, struct module *mod)
18491849
buf_printf(b, "};\n");
18501850
}
18511851

1852+
static void add_intree_flag(struct buffer *b, int is_intree)
1853+
{
1854+
if (is_intree)
1855+
buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");
1856+
}
1857+
18521858
static void add_staging_flag(struct buffer *b, const char *name)
18531859
{
18541860
static const char *staging_dir = "drivers/staging";
@@ -2169,6 +2175,7 @@ int main(int argc, char **argv)
21692175
buf.pos = 0;
21702176

21712177
add_header(&buf, mod);
2178+
add_intree_flag(&buf, !external_module);
21722179
add_staging_flag(&buf, mod->name);
21732180
err |= add_versions(&buf, mod);
21742181
add_depends(&buf, mod, modules);

0 commit comments

Comments
 (0)