From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH] module: Prevent recursion bug caused by module RCU check
Date: Tue, 20 Oct 2015 18:39:52 +0200 [thread overview]
Message-ID: <20151020163952.GI17308@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20151020122103.66ab250a@gandalf.local.home>
On Tue, Oct 20, 2015 at 12:21:03PM -0400, Steven Rostedt wrote:
> +++ b/kernel/module.c
> @@ -284,11 +284,25 @@ static void module_assert_mutex(void)
> static void module_assert_mutex_or_preempt(void)
> {
> #ifdef CONFIG_LOCKDEP
> + static int once;
> +
> if (unlikely(!debug_locks))
> return;
>
> - WARN_ON(!rcu_read_lock_sched_held() &&
> - !lockdep_is_held(&module_mutex));
> + /*
> + * Would be nice to use WARN_ON_ONCE(), but the warning
> + * that causes a stack trace may call __module_address()
> + * which may call here, and we trigger the warning again,
> + * before the WARN_ON_ONCE() updates its flag.
> + * To prevent the recursion, we need to open code the
> + * once logic.
> + */
> + if (!once &&
> + unlikely(!rcu_read_lock_sched_held() &&
> + !lockdep_is_held(&module_mutex))) {
> + once++;
once = 1;
is more 'once' :-) Otherwise its once every 4-odd billion.
> + WARN_ON(1);
> + }
> #endif
> }
>
next prev parent reply other threads:[~2015-10-20 16:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 16:21 [PATCH] module: Prevent recursion bug caused by module RCU check Steven Rostedt
2015-10-20 16:39 ` Peter Zijlstra [this message]
2015-10-20 16:46 ` Steven Rostedt
2015-10-20 16:56 ` Peter Zijlstra
2015-10-20 16:53 ` Peter Zijlstra
2015-10-20 17:09 ` Peter Zijlstra
2015-10-20 18:20 ` Steven Rostedt
2015-10-21 5:04 ` Rusty Russell
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=20151020163952.GI17308@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.