Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1984505pxx; Sat, 31 Oct 2020 04:51:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4VEZAX4uzSZPAYuae8zjizEWQXFW90SiM4BWhx1LzEtKu5IrStt0p8Yh+Z1YRRCb1m/VW X-Received: by 2002:a50:83e5:: with SMTP id 92mr7411068edi.307.1604145074066; Sat, 31 Oct 2020 04:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604145074; cv=none; d=google.com; s=arc-20160816; b=FMCZ1tDBfIX6Y7wj540Xs+s/BCk0Vm5HQxWVKrq47XSbAFrw8rP0yB5hrZScUgsZnf 3+4x9cnX6nsF9g9LB0V6DXIx6txRLyECZsyUU+8XJj+rQSxRAZ7wXtJyuJeL67MlV0o7 E/+7xha3Ny39IPivACk3uXZBa2KgCpPtL1nmftcjb8GAoEbRqUmdvkid15UPlYSeeZo4 6JsLj2rcLknwVvx5rjC4pGdkh1bFVft4HYoRZgLwSN+o+7TIGln7UXORaTTThfUkoSH9 EOcltPRB4hqFCHvLNWETT/ZcpAVtc5njgfFvQ0CSY6g56Vf8EVyUXeZnlegoU7V02omC cohg== 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=18+ENOdzKSk2fzW3yOzmSTvAfQp3F0VFpVg9IZziXD0=; b=YYqVgS0wS6y+HX1/eM4J27EpFrzL82AYJ5HoKu/vOEYj9nmxEjZESpLTHqseeicM+T CYmMK4iYerQA2IfR4/9DQVOKGJy1pU7MPn/pEont1rnXDSUZheJP0u8gxdHY5J3jStlA YbsYC1dd3H1CBShiBUTUVFx98LvOF94cvq9BzNUMyzLD76QhEEuBQoC5EnBhstG56JLn h+l/tIp8YCre0i8tjCF76piGW3Ya1bFLaYl4hWB20gf4etmUTIrMI+gHHKFCynefFuwj UXNVQ/TnwuoTCriOy61IbFlTkzk1bsNoYJEhbtHHvcXHyELU5FdTVvof3VmjwhFViUgu CIrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="mRV/vLgh"; 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 c13si3783313edq.389.2020.10.31.04.50.51; Sat, 31 Oct 2020 04:51:14 -0700 (PDT) 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="mRV/vLgh"; 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 S1728121AbgJaLtG (ORCPT + 99 others); Sat, 31 Oct 2020 07:49:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:42998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727950AbgJaLnI (ORCPT ); Sat, 31 Oct 2020 07:43:08 -0400 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 30FFC20731; Sat, 31 Oct 2020 11:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144587; bh=QGqN73TlyPV9Esx6Em0+u7wW5ISeEhOcwbfgUOltegY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mRV/vLghXDsIcZYHj/Lr13/HOy2vF7TLfnEoBkNRGMaWYs9OcYRwWrtxfNUVa0GQX si4Jc5M3aJ4SWa3SkAh0gRTvfcFmKHhTSpccc+lIY51rFWupNtKEZ6hgs5wOpa1eCb F7UNDHlgdjXQTYRYzYucs/kmmchPr2HVhOmK6w7I= 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 5.8 58/70] p54: avoid accessing the data mapped to streaming DMA Date: Sat, 31 Oct 2020 12:36:30 +0100 Message-Id: <20201031113502.277009299@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@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 @@ -329,10 +329,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); @@ -346,7 +348,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;