Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4488593ivc; Tue, 3 Nov 2020 13:22:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8WQx+V2LqgZSwYhZEyaMfbA+7v4Q8o7LNybzJ0Mct4uH2jfdGgWo/KZ5v09op0a3Dm1C8 X-Received: by 2002:a17:906:519b:: with SMTP id y27mr20804324ejk.25.1604438542357; Tue, 03 Nov 2020 13:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604438542; cv=none; d=google.com; s=arc-20160816; b=M9k9Ditozlu5YuEXzUPspqpNux3ZaNg1YaiBNQyxXkIg58glcbmoou0Pmcje90JjTg SvONFsS+SKnJfMmEZkS52ExtHrGrMhNZnwUPx4ym4jxwnSwCLJcgW4Gy9iXzIEYxZZ5F CHdJhOx8wv8Y6DsxqycFbHll4YUOdcpKjgCXK5n/11DkCDRtOGpiyr9nE+LVpSbPcuQm uQxIq1ouIsKMdgjC6VA3wYFweAEFFnTWycM+P7gv7pG31+Y0u47U2n2dX63kGBcv56vj /JEcU4SilhmZHPQGIp8JTvgNDggUKjpXFImiJYBVX3xF6ZHQ4RQnouWPe44JGqKwBNUM FcmA== 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=hyUC0WMeFPkn6D1P7/J6aFPCBgtSn2Y0aK+Ule3lG6E=; b=zEu79+BKtrFvx3uVCOMbQxz/Rilr3CVbCbQE75fXJ2YLoHQhm44/drfrxnaDJFyHqZ iKSnacfNxIkJNBlq1NH+tMasT7Nu8nwiPH76sAx+aH81cW9/g0WBpCIzdxuLDZdVuZOu 3fMyEcYPaGz9fSIiKoii00W3qqPyzlWpfu742u+rcSMahi4XRM0G55CBr6h+NroxGJOn nhnxOaaljPNCnfRhTPxeySpdIy99Yznwdm5/leYRdiQeq6ABVI5PLKdNWKi6/Pe+XjiW yw/KUW/9XkDLwKMs888wx3wkZiMKbOZ45gNsGPJ94y7tMq6u845nXY5Tk+w8W9pg8CKc zhSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pBqmfJsi; 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=fail (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 c25si7304746edy.364.2020.11.03.13.21.59; Tue, 03 Nov 2020 13:22:22 -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=@kernel.org header.s=default header.b=pBqmfJsi; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388212AbgKCVIz (ORCPT + 99 others); Tue, 3 Nov 2020 16:08:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:48516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388632AbgKCVIx (ORCPT ); Tue, 3 Nov 2020 16:08:53 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6CAC21534; Tue, 3 Nov 2020 21:08:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437732; bh=Mq9T2I5lz78Cwv1Ns8Lttt5Ot8InoesOyxtqrAR41+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBqmfJsivNqCAGsSX4iYvRjb0JtaK1wdn7+UclCRACiFDlITnEkqQ76F+AyYt9pe5 qybO4fkr+LSPc5uP+PG2qTVpiyTmoaULuIBFR9fALrcX96ukZLgCM7eDWoaGfzPr56 hX27yWyV01iOVMCYNqSD7k31IRQPnE48dHMmKUMM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Christian Lamparter , Kalle Valo Subject: [PATCH 4.14 010/125] p54: avoid accessing the data mapped to streaming DMA Date: Tue, 3 Nov 2020 21:36:27 +0100 Message-Id: <20201103203158.241313300@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203156.372184213@linuxfoundation.org> References: <20201103203156.372184213@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: Jia-Ju Bai commit 478762855b5ae9f68fa6ead1edf7abada70fcd5f upstream. In p54p_tx(), skb->data is mapped to streaming DMA on line 337: mapping = pci_map_single(..., skb->data, ...); Then skb->data is accessed on line 349: desc->device_addr = ((struct p54_hdr *)skb->data)->req_id; This access may cause data inconsistency between CPU cache and hardware. To fix this problem, ((struct p54_hdr *)skb->data)->req_id is stored in a local variable before DMA mapping, and then the driver accesses this local variable instead of skb->data. Cc: Signed-off-by: Jia-Ju Bai Acked-by: Christian Lamparter Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20200802132949.26788-1-baijiaju@tsinghua.edu.cn Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intersil/p54/p54pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/wireless/intersil/p54/p54pci.c +++ b/drivers/net/wireless/intersil/p54/p54pci.c @@ -332,10 +332,12 @@ static void p54p_tx(struct ieee80211_hw struct p54p_desc *desc; dma_addr_t mapping; u32 idx, i; + __le32 device_addr; spin_lock_irqsave(&priv->lock, flags); idx = le32_to_cpu(ring_control->host_idx[1]); i = idx % ARRAY_SIZE(ring_control->tx_data); + device_addr = ((struct p54_hdr *)skb->data)->req_id; mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); @@ -349,7 +351,7 @@ static void p54p_tx(struct ieee80211_hw desc = &ring_control->tx_data[i]; desc->host_addr = cpu_to_le32(mapping); - desc->device_addr = ((struct p54_hdr *)skb->data)->req_id; + desc->device_addr = device_addr; desc->len = cpu_to_le16(skb->len); desc->flags = 0;