From: He Kuang <hekuang@huawei.com>
To: <rusty@rustcorp.com.au>
Cc: <wangnan0@huawei.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] module: Fix missing to hold module_mutex lock in module_kallsyms_lookup_name
Date: Mon, 27 Jul 2015 10:01:26 +0000 [thread overview]
Message-ID: <1437991286-101906-1-git-send-email-hekuang@huawei.com> (raw)
Function find_module_all() searches for module by name and must be
called with module_mutex. module_kallsyms_lookup_name() calls it without
this mutex which emits a warning message (CONFIG_LOCKDEP=y) by failed
assertion for testing this module_mutex lock, as following:
[ 202.877152] ------------[ cut here ]------------
[ 202.881070] WARNING: CPU: 0 PID: 1010 at kernel/module.c:281
module_assert_mutex+0x35/0x40()
[ 202.885446] Modules linked in: test_bpf
[ 202.886997] CPU: 0 PID: 1010 Comm: perf Tainted: G W 4.2.0-rc3+ #5
...
This patch wraps this call with mutex_{lock,unlock} and fix the bug.
Signed-off-by: He Kuang <hekuang@huawei.com>
---
kernel/module.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/module.c b/kernel/module.c
index 4d2b82e..43d728b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3802,8 +3802,10 @@ unsigned long module_kallsyms_lookup_name(const char *name)
/* Don't lock: we're in enough trouble already. */
preempt_disable();
if ((colon = strchr(name, ':')) != NULL) {
+ mutex_lock(&module_mutex);
if ((mod = find_module_all(name, colon - name, false)) != NULL)
ret = mod_find_symname(mod, colon+1);
+ mutex_unlock(&module_mutex);
} else {
list_for_each_entry_rcu(mod, &modules, list) {
if (mod->state == MODULE_STATE_UNFORMED)
--
1.8.5.2
next reply other threads:[~2015-07-27 10:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 10:01 He Kuang [this message]
2015-07-28 0:31 ` [PATCH] module: Fix missing to hold module_mutex lock in module_kallsyms_lookup_name Rusty Russell
2015-07-28 12:52 ` Peter Zijlstra
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=1437991286-101906-1-git-send-email-hekuang@huawei.com \
--to=hekuang@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=wangnan0@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