Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3831174pxu; Tue, 20 Oct 2020 01:22:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt6DFQU/06r21G5cmFN+Ldn6ujoFbRGIZ/2tfP9S1pllX7nei9hGqn8jgOKWqGiSTsrFJI X-Received: by 2002:a05:6402:36d:: with SMTP id s13mr1589122edw.203.1603182137138; Tue, 20 Oct 2020 01:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603182137; cv=none; d=google.com; s=arc-20160816; b=Iul7aLlzR5gFbroBE5gIDKBqbNzKVBVZ/Gg8B8EIxFLkLDSQRhLhHFi/d4ZXbryMay agf/I+UYli52vkYZRb0ceTtljhbP1fGbOgI50WiZTQShqwD/ZS+SYnv01WQCOXcr6n8j sXd+NA3VpxIDmHe0m6of3dKSCyaB91MdZgjv1fut+DkvvHmiQZgZyp7riO1MJR/Xju+B 1XSsMHumFAfT/oqQjeidzLxV2V0xzb8PRSRYllr47prMYyHeeaxukwHGNv4KcvOTgLSa h4r6sAFdGf5UIFHycaFxMU7gCqLn9To2NHAo6KznA6HbeWii1KUnUecL13BB/UxvrvoW wVSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject; bh=r2nra8ZFTwJ23+GkF1O76HTrEq+M1vfItZaWZqdyUjs=; b=0pLpHNWyB8B/tAbmeqtsqggXC4pUlNrShnWLJiPq0egG5mNaO9LFWn2Oloxzd9S7iz kySao41x9Fv71+YqeQsfaD0od+SmgN4ltKtnSd0DU6uDJsFEBIbneOMHJ1Kl9w3Z73KG RLMDzUWzbEpcNmV4Gk4EIHoHEBcKt3Jj27t2fUaaL7elZK2BC7Iinmq0x2yaJzw0Yywf ceX2AiToMkD/tsqiwziO0Im1vDGW1qqtnIg8x0LZj+Ine5Wq0vr8QAX9FJfsFvcbblTQ 7oMdLcqBOtKzVDb5bc67ACypbKQ9FoiY4pQtlQF/F1InUegi5xX/5U7QF/vhSQNhHmW4 Oq7w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si674090edx.292.2020.10.20.01.21.54; Tue, 20 Oct 2020 01:22:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727106AbgJSXDq (ORCPT + 99 others); Mon, 19 Oct 2020 19:03:46 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:36304 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726561AbgJSXDp (ORCPT ); Mon, 19 Oct 2020 19:03:45 -0400 X-Greylist: delayed 987 seconds by postgrey-1.27 at vger.kernel.org; Mon, 19 Oct 2020 19:03:44 EDT Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.93.0.4) (envelope-from ) id 1kUdvn-0005E1-Nf; Tue, 20 Oct 2020 00:47:07 +0200 Subject: Re: [PATCH] rtl8180: avoid accessing the data mapped to streaming DMA To: Jia-Ju Bai Cc: kvalo@codeaurora.org, davem@davemloft.net, kuba@kernel.org, vaibhavgupta40@gmail.com, christophe.jaillet@wanadoo.fr, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20201019025420.3789-1-baijiaju1990@gmail.com>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vdknNZNvJsrIJiu9gHl 680YjsxLMoa3t8/scC5jyM0qGr7RxtWKhSQ6IT3ROUR7VwfvJSkdNITU7zW5lh95xRsCVF5G xVR/i/mXwWum5GCHv/WN0pHhCiOHntaxTjWBsLOv5q0kpSFK2O9FSu4lUfgmvSMShkMnoqeI snSaTF5ELnqq9lBXNh+MGFY4paJisq7hZS3o7GEO6ta8efGHwM9ddIz94jKzlwCPh/A4rj1c G6eo1umaMVJ0Wn6T3L1feYfr7y+xRlH3crGhwbdZQt5lOcwu9ZdO0+hriAUk86Yq3tIeallL LdcyH5K8EdOYKFvrGbqY+4mnzfXmWQAhfzST+oZnAWzyLbZbCyGM1W9xtbJsfNFt/1N6X/C9 kknYzrxwFCsCsMBiwJCrbE2ZQqjnpOOhxvwoiSdrf47mvA8UVAnh+OAO8VjSFZm43eO67gi9 tR6M/RH/mMP+UNjpYpI/JBRpTYiCRID0oY2gh/SQgoSBRAivY8qaLFE56Dq8SLj65JMaGMWL Sg== Message-ID: Date: Tue, 20 Oct 2020 00:47:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201019025420.3789-1-baijiaju1990@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19.10.2020 04:54, Jia-Ju Bai wrote: > In rtl8180_tx(), skb->data is mapped to streaming DMA on line 476: > mapping = dma_map_single(..., skb->data, ...); > > On line 459, skb->data is assigned to hdr after cast: > struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; > > Then hdr->seq_ctrl is accessed on lines 540 and 541: > hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); > hdr->seq_ctrl |= cpu_to_le16(priv->seqno); > > These DMA accesses may cause data inconsistency between CPU and hardwre. > > To fix this problem, hdr->seq_ctrl is accessed before the DMA mapping. > This looks like a bug fix to me, shouldn't this have a Fixes: tag and be CC'ed to stable@? Maciej