From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752649AbbJTQqd (ORCPT ); Tue, 20 Oct 2015 12:46:33 -0400 Received: from smtprelay0209.hostedemail.com ([216.40.44.209]:43778 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751976AbbJTQqb (ORCPT ); Tue, 20 Oct 2015 12:46:31 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3871:3872:3874:5007:6261:7875:7901:8660:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12740:13069:13148:13230:13311:13357:14096:14097:21080:30012:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: girls78_55ce4f683a52d X-Filterd-Recvd-Size: 2182 Date: Tue, 20 Oct 2015 12:46:28 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: "Paul E. McKenney" , LKML , Rusty Russell Subject: Re: [PATCH] module: Prevent recursion bug caused by module RCU check Message-ID: <20151020124628.726ef8bf@gandalf.local.home> In-Reply-To: <20151020163952.GI17308@twins.programming.kicks-ass.net> References: <20151020122103.66ab250a@gandalf.local.home> <20151020163952.GI17308@twins.programming.kicks-ass.net> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Steve > > > + WARN_ON(1); > > + } > > #endif > > } > >