linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] module: avoid setting info->name early in case we can fall back to info->mod->name
@ 2020-01-17 14:53 Jessica Yu
  2020-01-20 15:57 ` Miroslav Benes
  0 siblings, 1 reply; 3+ messages in thread
From: Jessica Yu @ 2020-01-17 14:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jessica Yu

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()")
Signed-off-by: Jessica Yu <jeyu@kernel.org>
---
 kernel/module.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 2b5f9c4748bc..f2379e54fae8 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -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 */
 	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. */
@@ -3076,14 +3074,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. */
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] module: avoid setting info->name early in case we can fall back to info->mod->name
  2020-01-17 14:53 [PATCH] module: avoid setting info->name early in case we can fall back to info->mod->name Jessica Yu
@ 2020-01-20 15:57 ` Miroslav Benes
  2020-01-21  8:48   ` Jessica Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Miroslav Benes @ 2020-01-20 15:57 UTC (permalink / raw)
  To: Jessica Yu; +Cc: linux-kernel

On Fri, 17 Jan 2020, Jessica Yu wrote:

> 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()")
> Signed-off-by: Jessica Yu <jeyu@kernel.org>

Reviewed-by: Miroslav Benes <mbenes@suse.cz>

M

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] module: avoid setting info->name early in case we can fall back to info->mod->name
  2020-01-20 15:57 ` Miroslav Benes
@ 2020-01-21  8:48   ` Jessica Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Jessica Yu @ 2020-01-21  8:48 UTC (permalink / raw)
  To: Miroslav Benes; +Cc: linux-kernel

+++ Miroslav Benes [20/01/20 16:57 +0100]:
>On Fri, 17 Jan 2020, Jessica Yu wrote:
>
>> 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()")
>> Signed-off-by: Jessica Yu <jeyu@kernel.org>
>
>Reviewed-by: Miroslav Benes <mbenes@suse.cz>

Applied, thanks!

Jessica


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-21  8:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 14:53 [PATCH] module: avoid setting info->name early in case we can fall back to info->mod->name Jessica Yu
2020-01-20 15:57 ` Miroslav Benes
2020-01-21  8:48   ` Jessica Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).