Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3630680pxb; Mon, 24 Jan 2022 13:58:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSEcoA8aTe/Wv2GxeJUpJK7n8DNZmE31n7Gz+4YoopYtDNpqI8W8T3SUIErfJRfM1ReH90 X-Received: by 2002:a17:903:2342:b0:14b:449:d517 with SMTP id c2-20020a170903234200b0014b0449d517mr16205119plh.104.1643061483936; Mon, 24 Jan 2022 13:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061483; cv=none; d=google.com; s=arc-20160816; b=kdzshEY2AFY9Z/Cnx076Y6TS0aj9s4HB9ub8vSZvhSCS0u7MNtjpKmnlci49sSZdeg 67ho05iaRVrIDyKbFt/HBtRHGUgBN8QKltp24YLsOiRgnPvg7Xga4OAjXhOSOg5z9QQ8 nro+mb3I8AibQ2How4VUdYEHivevu8emNJKjnTWxBswtapX5EyoEMg5itwZtx+JeputS OjUqY6+8B8XDN17p4uBHiGx1g4GhnT73DSWscIhuQDunAp1WPwbk1z1hoMmBI4e/LNIp 4fFzTpBpz2QlrpBfH2YbF9wNiVt/ntV3LRnxpv+uMPNVAMguCgRRUz4xwJnQ2XYPqH+b IhWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KZfhRDl+YbLTMq/ZsV9VB+RfNW4RAISUmk/OCEIvMcw=; b=RsIvGxcdHMq7uwKDCYKLhLXIGAx9N/P7Jc7KUifnqqorD7khJWCyR1gAZLQ8woarOd srbD5MZTEqUxoxim9ose4NuRDDo8/m/vhLHrodhrSzNcd5h1Pclls/5sx+RhUoO6AzwP rHnGld2mweTiSNV1Soz/z4s8eRitY29kDTMCiNU9KtIrbQk7rkoTDkhSO4qbun5D7Mii 89kx1RqLPsqdLIFZpsyXXGTAgszbg/nSSYJYlgzDK0vAVokOEmHkUAtyqKBNNxUmzdXb zwFGKIz7NaHT3Lwh5H7Oe+zIcW6dLNIWB30OAgwy5TEcLV9UrDyMc/Y23s+zihDeU/iU EodQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IThzIYw3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si13663637pls.160.2022.01.24.13.57.49; Mon, 24 Jan 2022 13:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IThzIYw3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573774AbiAXVpw (ORCPT + 99 others); Mon, 24 Jan 2022 16:45:52 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:59590 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446298AbiAXVHw (ORCPT ); Mon, 24 Jan 2022 16:07:52 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 00552B81243; Mon, 24 Jan 2022 21:07:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AD69C340E5; Mon, 24 Jan 2022 21:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058466; bh=RkngHeAeVCkGRFWJ2UEUeqVNrmIJmwasCnUlDu8quqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IThzIYw3M/+hwDBfvsf76rYyknVt1zD4oeoYhGhBoBsNrE3Y6RFeqNDm4PPkC/pX5 b4R9RB4fS4IBMqmJXFUvGejSl36Y1G4fqbqpWZgRCMQXLRoSolOKl40z2D1NpGK0is C7hrGUQWL5/FNnpZ0+BaExEinUHwF4386R3rgPeY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , TOTE Robot , Brian Norris , Kalle Valo , Sasha Levin Subject: [PATCH 5.16 0265/1039] mwifiex: Fix possible ABBA deadlock Date: Mon, 24 Jan 2022 19:34:14 +0100 Message-Id: <20220124184134.207274633@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brian Norris [ Upstream commit 1b8bb8919ef81bfc8873d223b9361f1685f2106d ] 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 Reviewed-by: Douglas Anderson Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/YaV0pllJ5p/EuUat@google.com Signed-off-by: Sasha Levin --- 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 68c63268e2e6b..2b2e6e0166e14 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.1