From: Peter Zijlstra <peterz@infradead.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: He Kuang <hekuang@huawei.com>,
wangnan0@huawei.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] module: Fix missing to hold module_mutex lock in module_kallsyms_lookup_name
Date: Tue, 28 Jul 2015 14:52:33 +0200 [thread overview]
Message-ID: <20150728125233.GA19282@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <878ua1p1g8.fsf@rustcorp.com.au>
On Tue, Jul 28, 2015 at 10:01:35AM +0930, Rusty Russell wrote:
> Peter?
> module: weaken locking assertion for oops path.
>
> We don't actually hold the module_mutex when calling find_module_all
> from module_kallsyms_lookup_name: that's because it's used by the oops
> code and we don't want to deadlock.
>
> However, access to the list read-only is safe if preempt is disabled,
> so we can weaken the assertion. Keep a strong version for external
> callers though.
>
> Fixes: 0be964be0d45 ("module: Sanitize RCU usage and locking")
> Reported-by: He Kuang <hekuang@huawei.com>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 4d2b82e610e2..b86b7bf1be38 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -602,13 +602,16 @@ const struct kernel_symbol *find_symbol(const char *name,
> }
> EXPORT_SYMBOL_GPL(find_symbol);
>
> -/* Search for module by name: must hold module_mutex. */
> +/*
> + * Search for module by name: must hold module_mutex (or preempt disabled
> + * for read-only access).
> + */
> static struct module *find_module_all(const char *name, size_t len,
> bool even_unformed)
> {
> struct module *mod;
>
> - module_assert_mutex();
> + module_assert_mutex_or_preempt();
Yeah, that should be fine indeed, I went by that comment you just
expanded.
The operation itself does indeed not modify data at all, so the
preempt_disable is perfectly adequate.
Thanks!
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
prev parent reply other threads:[~2015-07-28 12:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 10:01 [PATCH] module: Fix missing to hold module_mutex lock in module_kallsyms_lookup_name He Kuang
2015-07-28 0:31 ` Rusty Russell
2015-07-28 12:52 ` Peter Zijlstra [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=20150728125233.GA19282@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=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