Skip to content

Commit 708e0ad

Browse files
author
Jessica Yu
committed
module: avoid setting info->name early in case we can fall back to info->mod->name
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: 5fdc7db ("module: setup load info before module_sig_check()") Reviewed-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Jessica Yu <jeyu@kernel.org>
1 parent e9f35f6 commit 708e0ad

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎kernel/module.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,9 +3059,7 @@ static int setup_load_info(struct load_info *info, int flags)
30593059

30603060
/* Try to find a name early so we can log errors with a module name */
30613061
info->index.info = find_sec(info, ".modinfo");
3062-
if (!info->index.info)
3063-
info->name = "(missing .modinfo section)";
3064-
else
3062+
if (info->index.info)
30653063
info->name = get_modinfo(info, "name");
30663064

30673065
/* Find internal symbols and strings. */
@@ -3076,14 +3074,15 @@ static int setup_load_info(struct load_info *info, int flags)
30763074
}
30773075

30783076
if (info->index.sym == 0) {
3079-
pr_warn("%s: module has no symbols (stripped?)\n", info->name);
3077+
pr_warn("%s: module has no symbols (stripped?)\n",
3078+
info->name ?: "(missing .modinfo section or name field)");
30803079
return -ENOEXEC;
30813080
}
30823081

30833082
info->index.mod = find_sec(info, ".gnu.linkonce.this_module");
30843083
if (!info->index.mod) {
30853084
pr_warn("%s: No module found in object\n",
3086-
info->name ?: "(missing .modinfo name field)");
3085+
info->name ?: "(missing .modinfo section or name field)");
30873086
return -ENOEXEC;
30883087
}
30893088
/* This is temporary: point mod into copy of data. */

0 commit comments

Comments
 (0)