Commit ef1dac60 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jessica Yu

modules: return licensing information from find_symbol

Report the GPLONLY status through a new argument.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
parent cd8732cd
...@@ -582,7 +582,7 @@ struct module *find_module(const char *name); ...@@ -582,7 +582,7 @@ struct module *find_module(const char *name);
struct symsearch { struct symsearch {
const struct kernel_symbol *start, *stop; const struct kernel_symbol *start, *stop;
const s32 *crcs; const s32 *crcs;
enum { enum mod_license {
NOT_GPL_ONLY, NOT_GPL_ONLY,
GPL_ONLY, GPL_ONLY,
WILL_BE_GPL_ONLY, WILL_BE_GPL_ONLY,
......
...@@ -495,6 +495,7 @@ struct find_symbol_arg { ...@@ -495,6 +495,7 @@ struct find_symbol_arg {
struct module *owner; struct module *owner;
const s32 *crc; const s32 *crc;
const struct kernel_symbol *sym; const struct kernel_symbol *sym;
enum mod_license license;
}; };
static bool check_exported_symbol(const struct symsearch *syms, static bool check_exported_symbol(const struct symsearch *syms,
...@@ -528,6 +529,7 @@ static bool check_exported_symbol(const struct symsearch *syms, ...@@ -528,6 +529,7 @@ static bool check_exported_symbol(const struct symsearch *syms,
fsa->owner = owner; fsa->owner = owner;
fsa->crc = symversion(syms->crcs, symnum); fsa->crc = symversion(syms->crcs, symnum);
fsa->sym = &syms->start[symnum]; fsa->sym = &syms->start[symnum];
fsa->license = syms->license;
return true; return true;
} }
...@@ -587,6 +589,7 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms, ...@@ -587,6 +589,7 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms,
static const struct kernel_symbol *find_symbol(const char *name, static const struct kernel_symbol *find_symbol(const char *name,
struct module **owner, struct module **owner,
const s32 **crc, const s32 **crc,
enum mod_license *license,
bool gplok, bool gplok,
bool warn) bool warn)
{ {
...@@ -601,6 +604,8 @@ static const struct kernel_symbol *find_symbol(const char *name, ...@@ -601,6 +604,8 @@ static const struct kernel_symbol *find_symbol(const char *name,
*owner = fsa.owner; *owner = fsa.owner;
if (crc) if (crc)
*crc = fsa.crc; *crc = fsa.crc;
if (license)
*license = fsa.license;
return fsa.sym; return fsa.sym;
} }
...@@ -1074,7 +1079,7 @@ void __symbol_put(const char *symbol) ...@@ -1074,7 +1079,7 @@ void __symbol_put(const char *symbol)
struct module *owner; struct module *owner;
preempt_disable(); preempt_disable();
if (!find_symbol(symbol, &owner, NULL, true, false)) if (!find_symbol(symbol, &owner, NULL, NULL, true, false))
BUG(); BUG();
module_put(owner); module_put(owner);
preempt_enable(); preempt_enable();
...@@ -1352,7 +1357,7 @@ static inline int check_modstruct_version(const struct load_info *info, ...@@ -1352,7 +1357,7 @@ static inline int check_modstruct_version(const struct load_info *info,
* locking is necessary -- use preempt_disable() to placate lockdep. * locking is necessary -- use preempt_disable() to placate lockdep.
*/ */
preempt_disable(); preempt_disable();
if (!find_symbol("module_layout", NULL, &crc, true, false)) { if (!find_symbol("module_layout", NULL, &crc, NULL, true, false)) {
preempt_enable(); preempt_enable();
BUG(); BUG();
} }
...@@ -1436,6 +1441,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod, ...@@ -1436,6 +1441,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
struct module *owner; struct module *owner;
const struct kernel_symbol *sym; const struct kernel_symbol *sym;
const s32 *crc; const s32 *crc;
enum mod_license license;
int err; int err;
/* /*
...@@ -1445,7 +1451,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod, ...@@ -1445,7 +1451,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
*/ */
sched_annotate_sleep(); sched_annotate_sleep();
mutex_lock(&module_mutex); mutex_lock(&module_mutex);
sym = find_symbol(name, &owner, &crc, sym = find_symbol(name, &owner, &crc, &license,
!(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true);
if (!sym) if (!sym)
goto unlock; goto unlock;
...@@ -2213,7 +2219,7 @@ void *__symbol_get(const char *symbol) ...@@ -2213,7 +2219,7 @@ void *__symbol_get(const char *symbol)
const struct kernel_symbol *sym; const struct kernel_symbol *sym;
preempt_disable(); preempt_disable();
sym = find_symbol(symbol, &owner, NULL, true, true); sym = find_symbol(symbol, &owner, NULL, NULL, true, true);
if (sym && strong_try_module_get(owner)) if (sym && strong_try_module_get(owner))
sym = NULL; sym = NULL;
preempt_enable(); preempt_enable();
...@@ -2249,7 +2255,7 @@ static int verify_exported_symbols(struct module *mod) ...@@ -2249,7 +2255,7 @@ static int verify_exported_symbols(struct module *mod)
for (i = 0; i < ARRAY_SIZE(arr); i++) { for (i = 0; i < ARRAY_SIZE(arr); i++) {
for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) { for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
if (find_symbol(kernel_symbol_name(s), &owner, NULL, if (find_symbol(kernel_symbol_name(s), &owner, NULL,
true, false)) { NULL, true, false)) {
pr_err("%s: exports duplicate symbol %s" pr_err("%s: exports duplicate symbol %s"
" (owned by %s)\n", " (owned by %s)\n",
mod->name, kernel_symbol_name(s), mod->name, kernel_symbol_name(s),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment