Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3214305pxb; Mon, 9 Nov 2020 05:46:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzl8URgCNFIVX4/NR1z92yOpRQRQKtbjpNgBO3KkfX8Zqflk3RCcN8MWDXEBwnYnxJDANI3 X-Received: by 2002:a17:906:c41:: with SMTP id t1mr15209187ejf.19.1604929610119; Mon, 09 Nov 2020 05:46:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929610; cv=none; d=google.com; s=arc-20160816; b=uZw+ZcCucwxTjf0PG2ynUBDYkB6K0c8CwB/AeOIYjcqYOis8yx4bUmZEFDCujaxlz3 D2RNBjx9TZ3J10tUEgoDIXVt5QEOhsJsKUbQYmxHyOiBkQjNZpvcuwnqbad+D16SafYu n3rugvnmPGLZfQJ+ZanmkbRfPv7vFXwyj1bVorlDiDeCuIVQXKWXzEtkA0GLO80REwbK HKis0iRPJ95O0a7rYUzGJNb5ye/9+/d7IIZ1XQxhLW/XpJuiIQ7xCwk9BPMfn8Jcmpx8 Sn0oiLaIwYHOPSm14p1yKE/uDjf4aM2is9kxX/H/V5Nov8IR6CUbzeSDDvwiK7cHQeBg yICQ== 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=E3ZsAwV7OHqFw9YJUwx8o3xO9Q+1TPOHEid8pX/x8b8ncJvZ9S0JXbVoRRHmJXPr0f GxnjWRG6vGJ31oCK1t8VeVqpGx6KPhvfKmR1wrclFfQUJFEu9Rhl8KbNAmVyEnaICdb9 Xa/z+zIAYDXhgiI16yBWESwKQ8oEo/OyJIWydbxl4eurFA3tZWkxaRFE0hwCCr9f36BV 0xKXcRFAZfOrOleB9wtVoRXhmt1Q2XjEHHEIQd1u/mc9WrQKEMhstRaXg8Zrw1FgUoO7 a54NRKHlmGYzK2SKmXCyhZRlBxOxHV3vsHO8lvxAD/rTyjqVJPxR3/CwmI0KiwqvVCCY 3dOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EJcDzyGX; 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 s25si6688469ejv.48.2020.11.09.05.46.26; Mon, 09 Nov 2020 05:46:50 -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=EJcDzyGX; 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 S1731491AbgKINnN (ORCPT + 99 others); Mon, 9 Nov 2020 08:43:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:54562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730500AbgKINAX (ORCPT ); Mon, 9 Nov 2020 08:00:23 -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 A16C420789; Mon, 9 Nov 2020 13:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604926823; bh=Mq9T2I5lz78Cwv1Ns8Lttt5Ot8InoesOyxtqrAR41+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJcDzyGX194LnPxPk5dn6cCU9tMsUpFO3LVySSYE+y7clb6OBcQzJTMXjBWyaYbRW iy4icyixd8+z9sBQjezcmGbP4Tu/5sPbOfBAP+7KFVpb80Z4kLZYKlsOJmr+R7Ohw7 yc6l4Dg2RNvCx1VVkVNJQl2fLSnjcxANaIh14UYg= 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.9 009/117] p54: avoid accessing the data mapped to streaming DMA Date: Mon, 9 Nov 2020 13:53:55 +0100 Message-Id: <20201109125026.092455728@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@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;