mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
module: avoid setting info->name early in case we can fall back to info->mod->name
[ Upstream commit708e0ada19
] 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:5fdc7db644
("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>
This commit is contained in:
parent
7303a0b0a5
commit
496d6c0218
1 changed files with 4 additions and 5 deletions
|
@ -3059,9 +3059,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 */
|
/* Try to find a name early so we can log errors with a module name */
|
||||||
info->index.info = find_sec(info, ".modinfo");
|
info->index.info = find_sec(info, ".modinfo");
|
||||||
if (!info->index.info)
|
if (info->index.info)
|
||||||
info->name = "(missing .modinfo section)";
|
|
||||||
else
|
|
||||||
info->name = get_modinfo(info, "name");
|
info->name = get_modinfo(info, "name");
|
||||||
|
|
||||||
/* Find internal symbols and strings. */
|
/* Find internal symbols and strings. */
|
||||||
|
@ -3076,14 +3074,15 @@ static int setup_load_info(struct load_info *info, int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->index.sym == 0) {
|
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;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->index.mod = find_sec(info, ".gnu.linkonce.this_module");
|
info->index.mod = find_sec(info, ".gnu.linkonce.this_module");
|
||||||
if (!info->index.mod) {
|
if (!info->index.mod) {
|
||||||
pr_warn("%s: No module found in object\n",
|
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;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
/* This is temporary: point mod into copy of data. */
|
/* This is temporary: point mod into copy of data. */
|
||||||
|
|
Loading…
Reference in a new issue