summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Yu <jeyu@kernel.org>2020-01-17 13:32:21 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-24 08:34:49 +0100
commitc371b1e41f1392bb7a054712a412bd0a484fbed0 (patch)
tree75737acd2c3e9bba1a725ebc421ee9dfa5838278
parentf60d37409adab0034941b8670703e7560cde3660 (diff)
downloadlinux-stable-c371b1e41f1392bb7a054712a412bd0a484fbed0.tar.gz
linux-stable-c371b1e41f1392bb7a054712a412bd0a484fbed0.tar.bz2
linux-stable-c371b1e41f1392bb7a054712a412bd0a484fbed0.zip
module: avoid setting info->name early in case we can fall back to info->mod->name
[ Upstream commit 708e0ada1916be765b7faa58854062f2bc620bbf ] In setup_load_info(), info->name (which contains the name of the module, mostly used for early logging purposes before the module gets set up) gets unconditionally assigned if .modinfo is missing despite the fact that there is an if (!info->name) check near the end of the function. Avoid assigning a placeholder string to info->name if .modinfo doesn't exist, so that we can fall back to info->mod->name later on. Fixes: 5fdc7db6448a ("module: setup load info before module_sig_check()") Reviewed-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Jessica Yu <jeyu@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--kernel/module.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 70a75a7216ab..20fc0efc679c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2980,9 +2980,7 @@ static int setup_load_info(struct load_info *info, int flags)
/* Try to find a name early so we can log errors with a module name */
info->index.info = find_sec(info, ".modinfo");
- if (!info->index.info)
- info->name = "(missing .modinfo section)";
- else
+ if (info->index.info)
info->name = get_modinfo(info, "name");
/* Find internal symbols and strings. */
@@ -2997,14 +2995,15 @@ static int setup_load_info(struct load_info *info, int flags)
}
if (info->index.sym == 0) {
- pr_warn("%s: module has no symbols (stripped?)\n", info->name);
+ pr_warn("%s: module has no symbols (stripped?)\n",
+ info->name ?: "(missing .modinfo section or name field)");
return -ENOEXEC;
}
info->index.mod = find_sec(info, ".gnu.linkonce.this_module");
if (!info->index.mod) {
pr_warn("%s: No module found in object\n",
- info->name ?: "(missing .modinfo name field)");
+ info->name ?: "(missing .modinfo section or name field)");
return -ENOEXEC;
}
/* This is temporary: point mod into copy of data. */