Received: by 10.192.165.156 with SMTP id m28csp27713imm; Tue, 10 Apr 2018 15:41:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+j4SJwYegSJCioLnkGh0VJIWmeWcG/zZZJGMaFaZ4BTo+VWqfqYXlJ09GLvg3xbf+Docwc X-Received: by 10.98.156.91 with SMTP id f88mr1879474pfe.128.1523400090170; Tue, 10 Apr 2018 15:41:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523400090; cv=none; d=google.com; s=arc-20160816; b=gAeX9OvTNx5Xqp0reRPEgASDjD4Sl1Y+Ch90vxZvdSlmWWlm4AhgEmVmJKhKy3iC0D SKGBYHNSXvFdVf6aCgMe7ONO5M5zBSmjjuR8A33SfQX0t6vkR5w4E+4Vz2s0WOn7tEKu YkowV0SebVvXcx69bXq/qYwAh5H4lCzG4hCFcFHA754FKcf1ZR+qoiJWvB8qS+vsR0fg exMomIb9laNSjXDXoNCbIHcJw1nJUx8UiModKUVjKZG/pqHp1almI6iVCT9Yt+HAUTpT 9IFv8LJX5FKeG2HiuuUv/7udh9sVgMvLezW9wZYOFmkThLWkD87Qlw/0Ab9Z+bR5dxB1 gZEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wCR3u8BxWyiy7XW9LCdlQVsiaT0/ULFw7D8BbfpwN1I=; b=zxeo3mQvUbBygN2F2a8x3BGQ7ncWnzKfDqcfLp3UJ7AcQEcPqrf+L9JfPtS6jwo7nb TMcIceXWYXgTvjtWU4jvPHLepDWyd+mKl9JpHQzdELIMpbgOyCIID1wyNbH7OET8Jri+ ka24ejSjjhs1bp33icn1+JgsqArftjVt8A7jt4vhB/btVEPZjk6dFTkPGfT6gr85wI5v XNSa6WHkl2KQQQdTmzWzss8B1As+Sr00mwW2iizVaEoX6YmgU6s+Ioa8MYUIjS/i7nCG exprh2fnyTw6OzDiQ+oWsDyGHoVYnHrgTlvgiqTYvwBhsRadGJY9Vj4W6WbIPBAIPkqn wBUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1-v6si3586189plk.577.2018.04.10.15.40.54; Tue, 10 Apr 2018 15:41:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755706AbeDJWgt (ORCPT + 99 others); Tue, 10 Apr 2018 18:36:49 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43506 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755672AbeDJWgp (ORCPT ); Tue, 10 Apr 2018 18:36:45 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5AFE94A; Tue, 10 Apr 2018 22:36:40 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanislaw Gruszka , Enrico Mioso , Kalle Valo , Sasha Levin Subject: [PATCH 4.14 050/138] rt2x00: do not pause queue unconditionally on error path Date: Wed, 11 Apr 2018 00:24:00 +0200 Message-Id: <20180410212907.918717345@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stanislaw Gruszka [ Upstream commit 6dd80efd75ce7c2dbd9f117cf585ee2b33a42ee1 ] Pausing queue without checking threshold is racy with txdone path. Moreover we do not need pause queue on any error, but only if queue is full - in case when we send RTS frame ( other cases of almost full queue are already handled in rt2x00queue_write_tx_frame() ). Patch fixes of theoretically possible problem of pausing empty queue. Signed-off-by: Stanislaw Gruszka Tested-by: Enrico Mioso Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ralink/rt2x00/rt2x00mac.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) --- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c @@ -142,15 +142,25 @@ void rt2x00mac_tx(struct ieee80211_hw *h if (!rt2x00dev->ops->hw->set_rts_threshold && (tx_info->control.rates[0].flags & (IEEE80211_TX_RC_USE_RTS_CTS | IEEE80211_TX_RC_USE_CTS_PROTECT))) { - if (rt2x00queue_available(queue) <= 1) - goto exit_fail; + if (rt2x00queue_available(queue) <= 1) { + /* + * Recheck for full queue under lock to avoid race + * conditions with rt2x00lib_txdone(). + */ + spin_lock(&queue->tx_lock); + if (rt2x00queue_threshold(queue)) + rt2x00queue_pause_queue(queue); + spin_unlock(&queue->tx_lock); + + goto exit_free_skb; + } if (rt2x00mac_tx_rts_cts(rt2x00dev, queue, skb)) - goto exit_fail; + goto exit_free_skb; } if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false))) - goto exit_fail; + goto exit_free_skb; /* * Pausing queue has to be serialized with rt2x00lib_txdone(). Note @@ -164,10 +174,6 @@ void rt2x00mac_tx(struct ieee80211_hw *h return; - exit_fail: - spin_lock(&queue->tx_lock); - rt2x00queue_pause_queue(queue); - spin_unlock(&queue->tx_lock); exit_free_skb: ieee80211_free_txskb(hw, skb); }