Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9993FC433EF for ; Tue, 30 Nov 2021 00:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234459AbhK3Au4 (ORCPT ); Mon, 29 Nov 2021 19:50:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234379AbhK3Auz (ORCPT ); Mon, 29 Nov 2021 19:50:55 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28D69C061746 for ; Mon, 29 Nov 2021 16:47:37 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id m15so17870976pgu.11 for ; Mon, 29 Nov 2021 16:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FNHzIeoNF4E/ChvY8iqCZpHku0EJ1HjjIEUDqrvYteE=; b=hdoyQm+SZqT3VqIFKhsA87GHz6tPX+yEJy7VUqZ1vOh1fbV0K8hdAD8xEfN4BSZijq UyhMIWU5P7CpypZVPwH7GbgIRGa04Hb+DK5SWapT9cbNBnpIqzg77bQj3AvHEk7ojrJh 6xH4pD1x9Ltc9c5yLj5yuWR+HZqdVVal7S35g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FNHzIeoNF4E/ChvY8iqCZpHku0EJ1HjjIEUDqrvYteE=; b=r+xcMYuUZNB0BQ5M4I7TEndchxzXW/Vt5ybYp5AuTGvLuvzsZeWpEAQkJIK9t5OZ+N 8JeLqjiBYjxj2/NtjcrjpLu+DFagz5jyqP5k2Pww6FuY4fjH2qZgcEYZQXxHbvHRqXYv JJvhAsnpOqPqgo4RA7lBgkmpjPEWiwMMGA8evhAVeOPce0H3i64PcVw0ZFDNSgUt6I8s mqLzaOFg7ntql6UL9OIFSJ9/NznKEKy65Rb8NLw8Vfr6sZjGRJCJ91GWthX8GAJRSki3 LZR9rwHXtuSHA0UFbqysheKBdEIKvZiIHK23EX8dFZMLkciqYiUPDadvl6R83nNF6hEW yG0g== X-Gm-Message-State: AOAM530NMzZuYelFXOTsJ/4H+gEqdNpgXfwu6h5YDdO0SnN7jeEMiRq7 JLA1NHU+XdJrrhBE/JxnHV9TMw== X-Google-Smtp-Source: ABdhPJzqbcpo6hlWldDlPjrL230SXiWqrqs/mRNPc8dujTRCS/HMUGkCX5XfHZw0PIVrhJ83oQCu0g== X-Received: by 2002:a63:554:: with SMTP id 81mr34328310pgf.298.1638233256675; Mon, 29 Nov 2021 16:47:36 -0800 (PST) Received: from google.com ([2620:15c:202:201:8b47:583d:a0:4f2d]) by smtp.gmail.com with ESMTPSA id m12sm20441202pfk.27.2021.11.29.16.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 16:47:36 -0800 (PST) Date: Mon, 29 Nov 2021 16:47:34 -0800 From: Brian Norris To: Jia-Ju Bai Cc: amitkarwar@gmail.com, ganapathi017@gmail.com, sharvari.harisangam@nxp.com, huxinming820@gmail.com, kvalo@codeaurora.org, David Miller , kuba@kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel , Doug Anderson Subject: [PATCH] mwifiex: Fix possible ABBA deadlock Message-ID: References: <0e495b14-efbb-e0da-37bd-af6bd677ee2c@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0e495b14-efbb-e0da-37bd-af6bd677ee2c@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Jia-Ju Bai : mwifiex_dequeue_tx_packet() spin_lock_bh(&priv->wmm.ra_list_spinlock); --> Line 1432 (Lock A) mwifiex_send_addba() spin_lock_bh(&priv->sta_list_spinlock); --> Line 608 (Lock B) mwifiex_process_sta_tx_pause() spin_lock_bh(&priv->sta_list_spinlock); --> Line 398 (Lock B) mwifiex_update_ralist_tx_pause() spin_lock_bh(&priv->wmm.ra_list_spinlock); --> Line 941 (Lock A) Similar report for mwifiex_process_uap_tx_pause(). While the locking expectations in this driver are a bit unclear, the Fixed commit only intended to protect the sta_ptr, so we can drop the lock as soon as we're done with it. IIUC, this deadlock cannot actually happen, because command event processing (which calls mwifiex_process_sta_tx_pause()) is sequentialized with TX packet processing (e.g., mwifiex_dequeue_tx_packet()) via the main loop (mwifiex_main_process()). But it's good not to leave this potential issue lurking. Fixes: ("f0f7c2275fb9 mwifiex: minor cleanups w/ sta_list_spinlock in cfg80211.c") Cc: Douglas Anderson Reported-by: TOTE Robot Link: https://lore.kernel.org/linux-wireless/0e495b14-efbb-e0da-37bd-af6bd677ee2c@gmail.com/ Signed-off-by: Brian Norris --- On Tue, Nov 23, 2021 at 11:31:34AM +0800, Jia-Ju Bai wrote: > I am not quite sure whether these possible deadlocks are real and how to fix > them if they are real. > Any feedback would be appreciated, thanks :) I think these are at least theoretically real, and so we should take something like the $subject patch probably. But I don't believe we can actually hit this due to the main-loop structure of this driver. Anyway, see the surrounding patch. Thanks, Brian drivers/net/wireless/marvell/mwifiex/sta_event.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c b/drivers/net/wireless/marvell/mwifiex/sta_event.c index 80e5d44bad9d..7d42c5d2dbf6 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_event.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c @@ -365,10 +365,12 @@ static void mwifiex_process_uap_tx_pause(struct mwifiex_private *priv, sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac); if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) { sta_ptr->tx_pause = tp->tx_pause; + spin_unlock_bh(&priv->sta_list_spinlock); mwifiex_update_ralist_tx_pause(priv, tp->peermac, tp->tx_pause); + } else { + spin_unlock_bh(&priv->sta_list_spinlock); } - spin_unlock_bh(&priv->sta_list_spinlock); } } @@ -400,11 +402,13 @@ static void mwifiex_process_sta_tx_pause(struct mwifiex_private *priv, sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac); if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) { sta_ptr->tx_pause = tp->tx_pause; + spin_unlock_bh(&priv->sta_list_spinlock); mwifiex_update_ralist_tx_pause(priv, tp->peermac, tp->tx_pause); + } else { + spin_unlock_bh(&priv->sta_list_spinlock); } - spin_unlock_bh(&priv->sta_list_spinlock); } } } -- 2.34.0.rc2.393.gf8c9666880-goog