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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C99EDC43217 for ; Tue, 9 Nov 2021 01:01:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5BC0619F8 for ; Tue, 9 Nov 2021 01:01:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241818AbhKIBEa (ORCPT ); Mon, 8 Nov 2021 20:04:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:60498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241719AbhKIBDp (ORCPT ); Mon, 8 Nov 2021 20:03:45 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4801261360; Tue, 9 Nov 2021 01:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636419660; bh=DmZ12d8vtfZMFGEXcIlvrREGcummCyUH2u1kI5OhYH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W5Tbyk287Uvffbd++qZQLTwXGasfS4uGajs8eB0Sa7Ynw9nCodmSTx6n+9EaDTSyr 18fR620F1w3Il2sN3027asQrEVramfBuqELfZ8eVIUyf/AD+ykMxlWBFCty9KTcJnf akl+QIRP7jqBexkuMgIHJH6Nt7zvOHwfBZzL3D790eiSP7QYfp+yKfjY9N9vbZr8VD bZMaIlkPAVuE0Fvx/rORLpUalhSTKy+txH036GaOJQyrSzSTXFoki3MR4udXSo/ZZ7 4soVI1PVfdqAgQ+o5W/P966dOna4K/x2zYfV2Fke1bzz6Ied8vU+0Q7vjvqxQCra60 OiWRU/80o3NYw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Baochen Qiang , Kalle Valo , Sasha Levin , davem@davemloft.net, kuba@kernel.org, ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 035/146] ath11k: Change DMA_FROM_DEVICE to DMA_TO_DEVICE when map reinjected packets Date: Mon, 8 Nov 2021 12:43:02 -0500 Message-Id: <20211108174453.1187052-35-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211108174453.1187052-1-sashal@kernel.org> References: <20211108174453.1187052-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Baochen Qiang [ Upstream commit 86a03dad0f5ad8182ed5fcf7bf3eec71cd96577c ] For fragmented packets, ath11k reassembles each fragment as a normal packet and then reinjects it into HW ring. In this case, the DMA direction should be DMA_TO_DEVICE, not DMA_FROM_DEVICE, otherwise invalid payload will be reinjected to HW and then delivered to host. What is more, since arbitrary memory could be allocated to the frame, we don't know what kind of data is contained in the buffer reinjected. Thus, as a bad result, private info may be leaked. Note that this issue is only found on Intel platform. Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1 Signed-off-by: Baochen Qiang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20210916064617.20006-1-bqiang@codeaurora.org Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath11k/dp_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 9a224817630ae..af0a600ea067c 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -3310,7 +3310,7 @@ static int ath11k_dp_rx_h_defrag_reo_reinject(struct ath11k *ar, struct dp_rx_ti paddr = dma_map_single(ab->dev, defrag_skb->data, defrag_skb->len + skb_tailroom(defrag_skb), - DMA_FROM_DEVICE); + DMA_TO_DEVICE); if (dma_mapping_error(ab->dev, paddr)) return -ENOMEM; @@ -3375,7 +3375,7 @@ static int ath11k_dp_rx_h_defrag_reo_reinject(struct ath11k *ar, struct dp_rx_ti spin_unlock_bh(&rx_refill_ring->idr_lock); err_unmap_dma: dma_unmap_single(ab->dev, paddr, defrag_skb->len + skb_tailroom(defrag_skb), - DMA_FROM_DEVICE); + DMA_TO_DEVICE); return ret; } -- 2.33.0