Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f39710f3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Greg Kroah-Hartman
Browse files

UPSTREAM: modules: return licensing information from find_symbol



Report the GPLONLY status through a new argument.

Bug: 157965270
Bug: 171277690
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
(cherry picked from commit ef1dac6021cc8ec5de02ce31722bf26ac4ed5523)
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
Change-Id: I93285e06e380509b11356256da4d3d5a8738e252
parent 35601d50
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -573,7 +573,7 @@ struct module *find_module(const char *name);
struct symsearch {
	const struct kernel_symbol *start, *stop;
	const s32 *crcs;
	enum {
	enum mod_license {
		NOT_GPL_ONLY,
		GPL_ONLY,
		WILL_BE_GPL_ONLY,
+11 −5
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@ struct find_symbol_arg {
	struct module *owner;
	const s32 *crc;
	const struct kernel_symbol *sym;
	enum mod_license license;
};

static bool check_exported_symbol(const struct symsearch *syms,
@@ -525,6 +526,7 @@ static bool check_exported_symbol(const struct symsearch *syms,
	fsa->owner = owner;
	fsa->crc = symversion(syms->crcs, symnum);
	fsa->sym = &syms->start[symnum];
	fsa->license = syms->license;
	return true;
}

@@ -584,6 +586,7 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms,
static const struct kernel_symbol *find_symbol(const char *name,
					struct module **owner,
					const s32 **crc,
					enum mod_license *license,
					bool gplok,
					bool warn)
{
@@ -598,6 +601,8 @@ static const struct kernel_symbol *find_symbol(const char *name,
			*owner = fsa.owner;
		if (crc)
			*crc = fsa.crc;
		if (license)
			*license = fsa.license;
		return fsa.sym;
	}

@@ -1071,7 +1076,7 @@ void __symbol_put(const char *symbol)
	struct module *owner;

	preempt_disable();
	if (!find_symbol(symbol, &owner, NULL, true, false))
	if (!find_symbol(symbol, &owner, NULL, NULL, true, false))
		BUG();
	module_put(owner);
	preempt_enable();
@@ -1348,7 +1353,7 @@ static inline int check_modstruct_version(const struct load_info *info,
	 * locking is necessary -- use preempt_disable() to placate lockdep.
	 */
	preempt_disable();
	if (!find_symbol("module_layout", NULL, &crc, true, false)) {
	if (!find_symbol("module_layout", NULL, &crc, NULL, true, false)) {
		preempt_enable();
		BUG();
	}
@@ -1432,6 +1437,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
	struct module *owner;
	const struct kernel_symbol *sym;
	const s32 *crc;
	enum mod_license license;
	int err;

	/*
@@ -1441,7 +1447,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
	 */
	sched_annotate_sleep();
	mutex_lock(&module_mutex);
	sym = find_symbol(name, &owner, &crc,
	sym = find_symbol(name, &owner, &crc, &license,
			  !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true);
	if (!sym)
		goto unlock;
@@ -2263,7 +2269,7 @@ void *__symbol_get(const char *symbol)
	const struct kernel_symbol *sym;

	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))
		sym = NULL;
	preempt_enable();
@@ -2298,7 +2304,7 @@ static int verify_exported_symbols(struct module *mod)
	for (i = 0; i < ARRAY_SIZE(arr); i++) {
		for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
			if (find_symbol(kernel_symbol_name(s), &owner, NULL,
					true, false)) {
					NULL, true, false)) {
				pr_err("%s: exports duplicate symbol %s"
				       " (owned by %s)\n",
				       mod->name, kernel_symbol_name(s),