modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules

commit 9011e49d54 upstream.

It has recently come to my attention that nvidia is circumventing the
protection added in 262e6ae708 ("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: 262e6ae708 ("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>
This commit is contained in:
Christoph Hellwig 2023-08-01 19:35:44 +02:00 committed by Greg Kroah-Hartman
parent de37c3fbab
commit 35c739f793

View File

@ -2227,15 +2227,26 @@ static void free_module(struct module *mod)
void *__symbol_get(const char *symbol) void *__symbol_get(const char *symbol)
{ {
struct module *owner; struct module *owner;
enum mod_license license;
const struct kernel_symbol *sym; const struct kernel_symbol *sym;
preempt_disable(); preempt_disable();
sym = find_symbol(symbol, &owner, NULL, NULL, true, true); sym = find_symbol(symbol, &owner, NULL, &license, true, true);
if (sym && strong_try_module_get(owner)) if (!sym)
goto fail;
if (license != GPL_ONLY) {
pr_warn("failing symbol_get of non-GPLONLY symbol %s.\n",
symbol);
goto fail;
}
if (strong_try_module_get(owner))
sym = NULL; sym = NULL;
preempt_enable(); preempt_enable();
return sym ? (void *)sym->value : NULL; return sym ? (void *)sym->value : NULL;
fail:
preempt_enable();
return NULL;
} }
EXPORT_SYMBOL_GPL(__symbol_get); EXPORT_SYMBOL_GPL(__symbol_get);