From patchwork Mon Aug 24 01:17:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 31080 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1ZTgPP-000113-Gr; Mon, 24 Aug 2015 03:18:47 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-6) with esmtp id 1ZTgPN-0002W9-46; Mon, 24 Aug 2015 03:18:47 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753536AbbHXBSC (ORCPT + 1 other); Sun, 23 Aug 2015 21:18:02 -0400 Received: from ozlabs.org ([103.22.144.67]:49760 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751594AbbHXBSB (ORCPT ); Sun, 23 Aug 2015 21:18:01 -0400 Received: by ozlabs.org (Postfix, from userid 1011) id C82B9140518; Mon, 24 Aug 2015 11:17:59 +1000 (AEST) From: Rusty Russell To: poma , Linux Kernel list , Peter Zijlstra , Laura Abbott Cc: linux-media Subject: Re: WARNING: CPU: 1 PID: 813 at kernel/module.c:291 module_assert_mutex_or_preempt+0x49/0x90() In-Reply-To: <55D6FBB0.5000709@gmail.com> References: <55C916F0.8010303@gmail.com> <55D6FBB0.5000709@gmail.com> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu) Date: Mon, 24 Aug 2015 10:47:46 +0930 Message-ID: <87h9npjxhh.fsf@rustcorp.com.au> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.8.24.11216 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, MSGID_ADDED_BY_MTA 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_URI_IN_BODY 0, __CT 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __HTTPS_URI 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_URI_TEXT 0, __PHISH_SPEAR_SUBJECT 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' poma writes: >> Ref. >> https://bugzilla.redhat.com/show_bug.cgi?id=1252167 >> https://bugzilla.kernel.org/show_bug.cgi?id=102631 >> > > You guys are really something. Hi Poma, I understand your frustration! I got involved via the other thread which didn't mention your bug report anywhere. I'm sure Laura was trying to be helpful by creating a minimal report, but the resulting patch erred in not crediting you. > First of all, as is evident here, I am the original reporter, not Laura Abbott . Thanks for clarifying that. I have fixed the commit message to credit you. See below. > -All- your comments including the final patch on this issue, are just plain wrong.[1] > > This patch only hides the actual problem with this particular device - the dual tuner combination driven by dvb_usb_af9015 & mxl5007t, broken by design since day one. Oh, there's definitely a real issue in the driver; this one is cosmetic. > Read the entire https://bugzilla.redhat.com/show_bug.cgi?id=1252167 > and stop this nonsense. > > NACK "module: Fix locking in symbol_put_addr()" Yeah, I've had days like this, too :( Anyway, thanks for finding this bug: if the driver init hadn't been screwed it wouldn't have taken that path and found this for us. Good luck with the other issue! Rusty. From 275d7d44d802ef271a42dc87ac091a495ba72fc5 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 20 Aug 2015 10:34:59 +0930 Subject: [PATCH] module: Fix locking in symbol_put_addr() Poma (on the way to another bug) reported an assertion triggering: [] module_assert_mutex_or_preempt+0x49/0x90 [] __module_address+0x32/0x150 [] __module_text_address+0x16/0x70 [] symbol_put_addr+0x29/0x40 [] dvb_frontend_detach+0x7d/0x90 [dvb_core] Laura Abbott produced a patch which lead us to inspect symbol_put_addr(). This function has a comment claiming it doesn't need to disable preemption around the module lookup because it holds a reference to the module it wants to find, which therefore cannot go away. This is wrong (and a false optimization too, preempt_disable() is really rather cheap, and I doubt any of this is on uber critical paths, otherwise it would've retained a pointer to the actual module anyway and avoided the second lookup). While its true that the module cannot go away while we hold a reference on it, the data structure we do the lookup in very much _CAN_ change while we do the lookup. Therefore fix the comment and add the required preempt_disable(). Reported-by: poma Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Rusty Russell Fixes: a6e6abd575fc ("module: remove module_text_address()") Cc: stable@kernel.org --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/kernel/module.c b/kernel/module.c index b86b7bf1be38..8f051a106676 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1063,11 +1063,15 @@ void symbol_put_addr(void *addr) if (core_kernel_text(a)) return; - /* module_text_address is safe here: we're supposed to have reference - * to module from symbol_get, so it can't go away. */ + /* + * Even though we hold a reference on the module; we still need to + * disable preemption in order to safely traverse the data structure. + */ + preempt_disable(); modaddr = __module_text_address(a); BUG_ON(!modaddr); module_put(modaddr); + preempt_enable(); } EXPORT_SYMBOL_GPL(symbol_put_addr);