From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00D1650288; Tue, 14 May 2024 10:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715682805; cv=none; b=nCdlJpsqLw9CNEKRjlvqyNGXgJZLQb3t9yvT49Yrq9ZcNP20yfNjdqxxlBQYard8pP6rhYZpcdYJWkxGbb6xUTFh9CKCwl3SJhNsLkl986iKD2rTgllTW3NFGN+ibzQttl2dpzKbEyDFRSE3fo86+LFzvByB0/81bwUoQI2txZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715682805; c=relaxed/simple; bh=0zuZg89sKUIhVTC0ov2iVHk620pnHf+bxF9kgNp0dhk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AJOBAjyGlcB7UsL6jYR1WLyclj1ZImCAkUv277hK3dYkkHhavhy7F4YxTO3335HoHabNi+0DhX7X7mbgfsdB1DGts1RRbkD0zssa/0lOKcABZK3VrMcwz7otfZnfwKpeFbQaFmg0AaWMkjP4DjVfAfV83+DA58i8iBTN86hIp8o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gYORrd31; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gYORrd31" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 007D7C2BD10; Tue, 14 May 2024 10:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1715682804; bh=0zuZg89sKUIhVTC0ov2iVHk620pnHf+bxF9kgNp0dhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gYORrd311cHdd8KCjtnwVeBZEbcSijm3nxMcnqOXcy/UXcC6WmxD/h8ea/oWlWceE IZqKDZUpiW3kUgsqtcFLngYhJLMuNW9ZU8gkP5PdRsgdAwaVgdgjNt4WtMWDIIgd1u HdcFW7paPOjqfd2g55J1pEs2ssqnWUbi/oj6LwtU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Berg , Miri Korenblit , Sasha Levin Subject: [PATCH 6.8 108/336] wifi: iwlwifi: read txq->read_ptr under lock Date: Tue, 14 May 2024 12:15:12 +0200 Message-ID: <20240514101042.682608950@linuxfoundation.org> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514101038.595152603@linuxfoundation.org> References: <20240514101038.595152603@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Berg [ Upstream commit c2ace6300600c634553657785dfe5ea0ed688ac2 ] If we read txq->read_ptr without lock, we can read the same value twice, then obtain the lock, and reclaim from there to two different places, but crucially reclaim the same entry twice, resulting in the WARN_ONCE() a little later. Fix that by reading txq->read_ptr under lock. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit Link: https://msgid.link/20240319100755.bf4c62196504.I978a7ca56c6bd6f1bf42c15aa923ba03366a840b@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/queue/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/queue/tx.c b/drivers/net/wireless/intel/iwlwifi/queue/tx.c index ca74b1b63cac1..0efa304904bd3 100644 --- a/drivers/net/wireless/intel/iwlwifi/queue/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/queue/tx.c @@ -1588,9 +1588,9 @@ void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn, return; tfd_num = iwl_txq_get_cmd_index(txq, ssn); - read_ptr = iwl_txq_get_cmd_index(txq, txq->read_ptr); spin_lock_bh(&txq->lock); + read_ptr = iwl_txq_get_cmd_index(txq, txq->read_ptr); if (!test_bit(txq_id, trans->txqs.queue_used)) { IWL_DEBUG_TX_QUEUES(trans, "Q %d inactive - ignoring idx %d\n", -- 2.43.0