From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751172AbdEaMPx (ORCPT ); Wed, 31 May 2017 08:15:53 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37768 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751071AbdEaMPv (ORCPT ); Wed, 31 May 2017 08:15:51 -0400 Subject: Re: [PATCH] b43legacy: Fix a sleep-in-atomic bug in b43legacy_op_bss_info_changed To: Kalle Valo , Jia-Ju Bai Cc: Larry.Finger@lwfinger.net, linux-wireless@vger.kernel.org, b43-dev@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1496225353-5544-1-git-send-email-baijiaju1990@163.com> <877f0xnwyk.fsf@kamboji.qca.qualcomm.com> From: Arend van Spriel Message-ID: <471e5030-0a9a-e9bb-855c-90dcd506f466@broadcom.com> Date: Wed, 31 May 2017 14:15:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <877f0xnwyk.fsf@kamboji.qca.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31-05-17 12:26, Kalle Valo wrote: > Jia-Ju Bai writes: > >> The driver may sleep under a spin lock, and the function call path is: >> b43legacy_op_bss_info_changed (acquire the lock by spin_lock_irqsave) >> b43legacy_synchronize_irq >> synchronize_irq --> may sleep >> >> To fix it, the lock is released before b43legacy_synchronize_irq, and the >> lock is acquired again after this function. >> >> Signed-off-by: Jia-Ju Bai >> --- >> drivers/net/wireless/broadcom/b43legacy/main.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/net/wireless/broadcom/b43legacy/main.c b/drivers/net/wireless/broadcom/b43legacy/main.c >> index f1e3dad..31ead21 100644 >> --- a/drivers/net/wireless/broadcom/b43legacy/main.c >> +++ b/drivers/net/wireless/broadcom/b43legacy/main.c >> @@ -2859,7 +2859,9 @@ static void b43legacy_op_bss_info_changed(struct ieee80211_hw *hw, >> b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, 0); >> >> if (changed & BSS_CHANGED_BSSID) { >> + spin_unlock_irqrestore(&wl->irq_lock, flags); >> b43legacy_synchronize_irq(dev); >> + spin_lock_irqsave(&wl->irq_lock, flags); > > To me this looks like a fragile workaround and not a real fix. You can > easily add new race conditions with releasing the lock like this. Hi Jia-Ju, Agree with Kalle as I was about to say the same thing. You really need to determine what is protected by the irq_lock. Here you are using the lock because you are about to change wl->bssid a bit further down. Did not check the entire function but it seems the lock perimeter is too wide. Regards, Arend