Skip to content

Commit c8e0bd5

Browse files
Uwe Kleine-Königpetrpavlu
authored andcommitted
module: Put known GPL offenders in an array
Instead of repeating the add_taint_module() call for each offender, create an array and loop over that one. This simplifies adding new entries considerably. Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Werner Sembach <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ppavlu: make the array const] Signed-off-by: Petr Pavlu <[email protected]>
1 parent a145c84 commit c8e0bd5

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

kernel/module/main.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,11 +2332,20 @@ static int rewrite_section_headers(struct load_info *info, int flags)
23322332
return 0;
23332333
}
23342334

2335+
static const char *const module_license_offenders[] = {
2336+
/* driverloader was caught wrongly pretending to be under GPL */
2337+
"driverloader",
2338+
2339+
/* lve claims to be GPL but upstream won't provide source */
2340+
"lve",
2341+
};
2342+
23352343
/*
23362344
* These calls taint the kernel depending certain module circumstances */
23372345
static void module_augment_kernel_taints(struct module *mod, struct load_info *info)
23382346
{
23392347
int prev_taint = test_taint(TAINT_PROPRIETARY_MODULE);
2348+
size_t i;
23402349

23412350
if (!get_modinfo(info, "intree")) {
23422351
if (!test_taint(TAINT_OOT_MODULE))
@@ -2385,15 +2394,11 @@ static void module_augment_kernel_taints(struct module *mod, struct load_info *i
23852394
if (strcmp(mod->name, "ndiswrapper") == 0)
23862395
add_taint(TAINT_PROPRIETARY_MODULE, LOCKDEP_NOW_UNRELIABLE);
23872396

2388-
/* driverloader was caught wrongly pretending to be under GPL */
2389-
if (strcmp(mod->name, "driverloader") == 0)
2390-
add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
2391-
LOCKDEP_NOW_UNRELIABLE);
2392-
2393-
/* lve claims to be GPL but upstream won't provide source */
2394-
if (strcmp(mod->name, "lve") == 0)
2395-
add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
2396-
LOCKDEP_NOW_UNRELIABLE);
2397+
for (i = 0; i < ARRAY_SIZE(module_license_offenders); ++i) {
2398+
if (strcmp(mod->name, module_license_offenders[i]) == 0)
2399+
add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
2400+
LOCKDEP_NOW_UNRELIABLE);
2401+
}
23972402

23982403
if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
23992404
pr_warn("%s: module license taints kernel.\n", mod->name);

0 commit comments

Comments
 (0)