lkml.org 
[lkml]   [2015]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] module: Prevent recursion bug caused by module RCU check
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
> }
>


\
 
 \ /
  Last update: 2015-10-20 19:01    [W:0.053 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site