mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jessica Yu <jeyu@kernel.org>
To: Zhou Chengming <zhouchengming1@huawei.com>
Cc: rusty@rustcorp.com.au, jpoimboe@redhat.com,
	linux-kernel@vger.kernel.org, huawei.libin@huawei.com
Subject: Re: module: fix ddebug_remove_module()
Date: Tue, 11 Jul 2017 16:32:37 +0200	[thread overview]
Message-ID: <20170711143235.lorte6hxa6xeqsfs@redbean> (raw)
In-Reply-To: <1499397358-91778-1-git-send-email-zhouchengming1@huawei.com>

+++ Zhou Chengming [07/07/17 11:15 +0800]:
>ddebug_remove_module() use mod->name to find the ddebug_table of the
>module and remove it. But dynamic_debug_setup() use the first
>_ddebug->modname to create ddebug_table for the module. It's ok when
>the _ddebug->modname is the same with the mod->name.
>
>But livepatch module is special, it may contain _ddebugs of other
>modules, the modname of which is different from the name of livepatch
>module. So ddebug_remove_module() can't use mod->name to find the

s/mod->name/_ddebug->modname/ :) I'll fix the typo in the changelog.

>right ddebug_table and remove it. It can cause kernel crash when we cat
>the file <debugfs>/dynamic_debug/control.
>
>Signed-off-by: Zhou Chengming <zhouchengming1@huawei.com>

Makes sense, I have this queued up to be applied to modules-next.

By the way, although I can see how livepatch modules can end up
including a hodgepodge of _ddebug entries from different modules,
wouldn't the correct thing to do be to have the modname of the
livepatch module instead of the modules they originally came from? I
think when the pr_debug's are enabled it'll print the name of the
original module instead of the livepatch module.

Jessica

> kernel/module.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/kernel/module.c b/kernel/module.c
>index 4a3665f..dac9805 100644
>--- a/kernel/module.c
>+++ b/kernel/module.c
>@@ -2703,21 +2703,21 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
> }
> #endif /* CONFIG_KALLSYMS */
>
>-static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num)
>+static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num)
> {
> 	if (!debug)
> 		return;
> #ifdef CONFIG_DYNAMIC_DEBUG
>-	if (ddebug_add_module(debug, num, debug->modname))
>+	if (ddebug_add_module(debug, num, mod->name))
> 		pr_err("dynamic debug error adding module: %s\n",
> 			debug->modname);
> #endif
> }
>
>-static void dynamic_debug_remove(struct _ddebug *debug)
>+static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug)
> {
> 	if (debug)
>-		ddebug_remove_module(debug->modname);
>+		ddebug_remove_module(mod->name);
> }
>
> void * __weak module_alloc(unsigned long size)
>@@ -3697,7 +3697,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
> 		goto free_arch_cleanup;
> 	}
>
>-	dynamic_debug_setup(info->debug, info->num_debug);
>+	dynamic_debug_setup(mod, info->debug, info->num_debug);
>
> 	/* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
> 	ftrace_module_init(mod);
>@@ -3761,7 +3761,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
> 	module_disable_nx(mod);
>
>  ddebug_cleanup:
>-	dynamic_debug_remove(info->debug);
>+	dynamic_debug_remove(mod, info->debug);
> 	synchronize_sched();
> 	kfree(mod->args);
>  free_arch_cleanup:
>-- 
>1.8.3.1
>

      reply	other threads:[~2017-07-11 14:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-07  3:15 [PATCH] " Zhou Chengming
2017-07-11 14:32 ` Jessica Yu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170711143235.lorte6hxa6xeqsfs@redbean \
    --to=jeyu@kernel.org \
    --cc=huawei.libin@huawei.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=zhouchengming1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®