diff mbox series

[1/2] module: Put known GPL offenders in an array

Message ID 20241114103133.547032-5-ukleinek@kernel.org (mailing list archive)
State New
Headers show
Series module: Block modules by Tuxedo from accessing GPL symbols | expand

Checks

Context Check Description
mcgrof/vmtest-modules-next-VM_Test-0 success Logs for Run CI tests
mcgrof/vmtest-modules-next-VM_Test-1 fail Logs for Run CI tests
mcgrof/vmtest-modules-next-VM_Test-4 fail Logs for setup / Setup kdevops environment
mcgrof/vmtest-modules-next-VM_Test-5 success Logs for setup / Setup kdevops environment
mcgrof/vmtest-modules-next-PR fail PR summary
mcgrof/vmtest-modules-next-VM_Test-2 success Logs for cleanup / Archive results and cleanup
mcgrof/vmtest-modules-next-VM_Test-3 success Logs for cleanup / Archive results and cleanup

Commit Message

Uwe Kleine-König Nov. 14, 2024, 10:31 a.m. UTC
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 <ukleinek@kernel.org>
---
 kernel/module/main.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

Comments

Christoph Hellwig Nov. 14, 2024, 4:08 p.m. UTC | #1
On Thu, Nov 14, 2024 at 11:31:33AM +0100, Uwe Kleine-König wrote:
> 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 <ukleinek@kernel.org>

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Greg KH Nov. 15, 2024, 4:40 a.m. UTC | #2
On Thu, Nov 14, 2024 at 11:31:33AM +0100, Uwe Kleine-König wrote:
> 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 <ukleinek@kernel.org>
> ---
>  kernel/module/main.c | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff mbox series

Patch

diff --git a/kernel/module/main.c b/kernel/module/main.c
index 5399c182b3cb..878191c65efc 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2332,11 +2332,20 @@  static int rewrite_section_headers(struct load_info *info, int flags)
 	return 0;
 }
 
+static const char *module_license_offenders[] = {
+	/* driverloader was caught wrongly pretending to be under GPL */
+	"driverloader",
+
+	/* lve claims to be GPL but upstream won't provide source */
+	"lve",
+};
+
 /*
  * These calls taint the kernel depending certain module circumstances */
 static void module_augment_kernel_taints(struct module *mod, struct load_info *info)
 {
 	int prev_taint = test_taint(TAINT_PROPRIETARY_MODULE);
+	size_t i;
 
 	if (!get_modinfo(info, "intree")) {
 		if (!test_taint(TAINT_OOT_MODULE))
@@ -2385,15 +2394,11 @@  static void module_augment_kernel_taints(struct module *mod, struct load_info *i
 	if (strcmp(mod->name, "ndiswrapper") == 0)
 		add_taint(TAINT_PROPRIETARY_MODULE, LOCKDEP_NOW_UNRELIABLE);
 
-	/* driverloader was caught wrongly pretending to be under GPL */
-	if (strcmp(mod->name, "driverloader") == 0)
-		add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
-				 LOCKDEP_NOW_UNRELIABLE);
-
-	/* lve claims to be GPL but upstream won't provide source */
-	if (strcmp(mod->name, "lve") == 0)
-		add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
-				 LOCKDEP_NOW_UNRELIABLE);
+	for (i = 0; i < ARRAY_SIZE(module_license_offenders); ++i) {
+		if (strcmp(mod->name, module_license_offenders[i]) == 0)
+			add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
+					 LOCKDEP_NOW_UNRELIABLE);
+	}
 
 	if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
 		pr_warn("%s: module license taints kernel.\n", mod->name);