Skip to content

Commit 262e6ae

Browse files
Christoph HellwigJessica Yu
authored andcommitted
modules: inherit TAINT_PROPRIETARY_MODULE
If a TAINT_PROPRIETARY_MODULE exports symbol, inherit the taint flag for all modules importing these symbols, and don't allow loading symbols from TAINT_PROPRIETARY_MODULE modules if the module previously imported gplonly symbols. Add a anti-circumvention devices so people don't accidentally get themselves into trouble this way. Comment from Greg: "Ah, the proven-to-be-illegal "GPL Condom" defense :)" [jeyu: pr_info -> pr_err and pr_warn as per discussion] Link: http://lore.kernel.org/r/[email protected] Acked-by: Daniel Vetter <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jessica Yu <[email protected]>
1 parent ef1dac6 commit 262e6ae

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

include/linux/module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ struct module {
389389
unsigned int num_gpl_syms;
390390
const struct kernel_symbol *gpl_syms;
391391
const s32 *gpl_crcs;
392+
bool using_gplonly_symbols;
392393

393394
#ifdef CONFIG_UNUSED_SYMBOLS
394395
/* unused exported symbols. */

kernel/module.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,24 @@ static int verify_namespace_is_imported(const struct load_info *info,
14311431
return 0;
14321432
}
14331433

1434+
static bool inherit_taint(struct module *mod, struct module *owner)
1435+
{
1436+
if (!owner || !test_bit(TAINT_PROPRIETARY_MODULE, &owner->taints))
1437+
return true;
1438+
1439+
if (mod->using_gplonly_symbols) {
1440+
pr_err("%s: module using GPL-only symbols uses symbols from proprietary module %s.\n",
1441+
mod->name, owner->name);
1442+
return false;
1443+
}
1444+
1445+
if (!test_bit(TAINT_PROPRIETARY_MODULE, &mod->taints)) {
1446+
pr_warn("%s: module uses symbols from proprietary module %s, inheriting taint.\n",
1447+
mod->name, owner->name);
1448+
set_bit(TAINT_PROPRIETARY_MODULE, &mod->taints);
1449+
}
1450+
return true;
1451+
}
14341452

14351453
/* Resolve a symbol for this module. I.e. if we find one, record usage. */
14361454
static const struct kernel_symbol *resolve_symbol(struct module *mod,
@@ -1456,6 +1474,14 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
14561474
if (!sym)
14571475
goto unlock;
14581476

1477+
if (license == GPL_ONLY)
1478+
mod->using_gplonly_symbols = true;
1479+
1480+
if (!inherit_taint(mod, owner)) {
1481+
sym = NULL;
1482+
goto getname;
1483+
}
1484+
14591485
if (!check_version(info, name, mod, crc)) {
14601486
sym = ERR_PTR(-EINVAL);
14611487
goto getname;

0 commit comments

Comments
 (0)