From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752224AbbJTQ4z (ORCPT ); Tue, 20 Oct 2015 12:56:55 -0400 Received: from casper.infradead.org ([85.118.1.10]:33407 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbbJTQ4w (ORCPT ); Tue, 20 Oct 2015 12:56:52 -0400 Date: Tue, 20 Oct 2015 18:56:49 +0200 From: Peter Zijlstra To: Steven Rostedt Cc: "Paul E. McKenney" , LKML , Rusty Russell Subject: Re: [PATCH] module: Prevent recursion bug caused by module RCU check Message-ID: <20151020165649.GJ17308@twins.programming.kicks-ass.net> References: <20151020122103.66ab250a@gandalf.local.home> <20151020163952.GI17308@twins.programming.kicks-ass.net> <20151020124628.726ef8bf@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151020124628.726ef8bf@gandalf.local.home> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 20, 2015 at 12:46:28PM -0400, Steven Rostedt wrote: > On Tue, 20 Oct 2015 18:39:52 +0200 > Peter Zijlstra wrote: > > > 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. > > Once it's not 0, it never gets incremented again. *sigh*, so much for pretending to be awake :-)