]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules
authorChristoph Hellwig <hch@lst.de>
Tue, 1 Aug 2023 17:35:44 +0000 (19:35 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 30 Oct 2023 11:00:32 +0000 (12:00 +0100)
BugLink: https://bugs.launchpad.net/bugs/2039884
commit 9011e49d54dcc7653ebb8a1e05b5badb5ecfa9f9 upstream.

It has recently come to my attention that nvidia is circumventing the
protection added in 262e6ae7081d ("modules: inherit
TAINT_PROPRIETARY_MODULE") by importing exports from their proprietary
modules into an allegedly GPL licensed module and then rexporting them.

Given that symbol_get was only ever intended for tightly cooperating
modules using very internal symbols it is logical to restrict it to
being used on EXPORT_SYMBOL_GPL and prevent nvidia from costly DMCA
Circumvention of Access Controls law suites.

All symbols except for four used through symbol_get were already exported
as EXPORT_SYMBOL_GPL, and the remaining four ones were switched over in
the preparation patches.

Fixes: 262e6ae7081d ("modules: inherit TAINT_PROPRIETARY_MODULE")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
kernel/module/main.c

index 57a3da409337a0c2876e8b7fff7f61f22d8042ce..de086f1d770fc137c6a9c7e2cc7ba5db24a3fd8d 100644 (file)
@@ -1211,12 +1211,20 @@ void *__symbol_get(const char *symbol)
        };
 
        preempt_disable();
-       if (!find_symbol(&fsa) || strong_try_module_get(fsa.owner)) {
-               preempt_enable();
-               return NULL;
+       if (!find_symbol(&fsa))
+               goto fail;
+       if (fsa.license != GPL_ONLY) {
+               pr_warn("failing symbol_get of non-GPLONLY symbol %s.\n",
+                       symbol);
+               goto fail;
        }
+       if (strong_try_module_get(fsa.owner))
+               goto fail;
        preempt_enable();
        return (void *)kernel_symbol_value(fsa.sym);
+fail:
+       preempt_enable();
+       return NULL;
 }
 EXPORT_SYMBOL_GPL(__symbol_get);