Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2250519rda; Tue, 24 Oct 2023 18:11:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcuSe2c/mmnmszfa5xHdnuMBIOJRaJhm2wW3et6MCqibnb50JvqKk3ECATHxGy+twM7iZF X-Received: by 2002:a05:6a21:4842:b0:15d:fc71:1b9e with SMTP id au2-20020a056a21484200b0015dfc711b9emr3832796pzc.49.1698196267482; Tue, 24 Oct 2023 18:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698196267; cv=none; d=google.com; s=arc-20160816; b=RUlhB7S5U8FOl1s4vldmEHCEtxlqtZjNZtP4SOLLk1pqYMGV6KJ6KKyQIDhrYT6AIu lUijEuyAWtd9UK4nZnqEIbLdLPTgd9MhXHI3C7TeoglHUgwepWyo+vTyxA/Rri7zLgzb 62/LFsoPLwJMRhc9J7Mdk2IaBpvltcYNen6RLglKh6qT/Q0fO7bZ0iPMA2tqmz7H5ISV xKhnmdOKph6JufJ9EhDNkXqamZzj+TD4WVooyK+wF3e5u5oHV38sncy+fccGV0PN4FE0 5fqnaAXRGZ04eDoAiWpX+/+OoqeKyrHDWxPrIWQeCFiWjnWhvuxptPH53AthfXJ3ZkLk Lneg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=jgueludWkZgknBALxo52tKnH1XcORBXqsInq+hMs+AA=; fh=WQatNQJ2xvV58jP6+OKwn5IhDYbrnhT1bt/YHPXeBVc=; b=y98eLu6XElap/EVB6BNWipPiCllyZHCoYWwEVLwleu+be1yYwTbk+M/jmwc5rhK7qA mE/J4IGlgX6sBhBbGdV06zUyC9+8BChkhVtuhOrgkDEAXx9Yy5wGEJ6WfxrVgGvtucuJ VcELrzWU5mDRGJHJvWDsZsV/ZnZ/MDp1Msep7uCBz3zvs4z+47kA8T6asNE8KTf1LgPI s9TLf3DAz+wfQus8r61fQfQxpVfcXhYNsKFbITwDeFICNhzAB/d//KwJA3cwnt4jXSf7 N+cCtcd6QZME0QfVFnokH8UqoaT5CnI8z7/clbWM0bYjQzvERgkGU/VkqnnXSmD0Mxtl 4/Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b="cVl4Aqq/"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u13-20020a056a00124d00b0068e256c6366si9450655pfi.352.2023.10.24.18.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 18:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b="cVl4Aqq/"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9A6C7807863C; Tue, 24 Oct 2023 18:10:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbjJYBHF (ORCPT + 52 others); Tue, 24 Oct 2023 21:07:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbjJYBHE (ORCPT ); Tue, 24 Oct 2023 21:07:04 -0400 Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4F6128 for ; Tue, 24 Oct 2023 18:07:02 -0700 (PDT) Received: from eig-obgw-6006a.ext.cloudfilter.net ([10.0.30.182]) by cmsmtp with ESMTPS id vRRcqi701hqFdvSMPqyVmY; Wed, 25 Oct 2023 01:07:01 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id vSMOqBCS51wVhvSMOqssja; Wed, 25 Oct 2023 01:07:01 +0000 X-Authority-Analysis: v=2.4 cv=ANu0s8gj c=1 sm=1 tr=0 ts=65386a35 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=WzbPXH4gqzPVN0x6HrNMNA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=_mNlVl-r0hj7kTaC:21 a=IkcTkHD0fZMA:10 a=bhdUkHdE2iEA:10 a=wYkD_t78qR0A:10 a=VwQbUJbxAAAA:8 a=stkexhm8AAAA:8 a=_Wotqz80AAAA:8 a=jR2mby-O1imw8BYHV3QA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX:22 a=pIW3pCRaVxJDc-hWtpF8:22 a=buJP51TR1BpY-zbLSsyS:22 a=N_l3Vs37sht3-TxgB6J7:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:References:Cc:To:From:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jgueludWkZgknBALxo52tKnH1XcORBXqsInq+hMs+AA=; b=cVl4Aqq/QtjRsb9reVAKMjUA4b JxcileGUcoYCD5yZH1ZltbFYWLZHYo+EiooYvbdsktidvQqdNwWQxu9GLFzQd2VSKbGU5AO3TmHSa 0OMAd7+7NRrRfcS+bDX/+jUSSb/MwVrTH7jQNRZCKEa/SXldSeJ1/H0BLtvEgyR7JGGVQ4YWnCWCJ klr2NqBRUoy6vu/GSdrXewRjfTA4ifuHKV8sCelFrzmJateexgzbTw2y8/NTSAg+RwXQbR7Hynmpl CyeTj6OFXGqO0PAeDC74NNODEmtLVuOiCgW7m4vZ6BeLDuPKEO6AxLmQ4HiVIRSFEreVNdZ2UUsiW zXMsqVgg==; Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:48400 helo=[192.168.15.10]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1qvSMO-001oyw-0H; Tue, 24 Oct 2023 20:07:00 -0500 Message-ID: Date: Tue, 24 Oct 2023 19:06:58 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC - is this a bug?] wifi: ath10k: Asking for some light on this, please :) Content-Language: en-US From: "Gustavo A. R. Silva" To: Kalle Valo , Jeff Johnson , Manikanta Pubbisetty Cc: ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org References: <626ae2e7-66f8-423b-b17f-e75c1a6d29b3@embeddedor.com> In-Reply-To: <626ae2e7-66f8-423b-b17f-e75c1a6d29b3@embeddedor.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.21.192 X-Source-L: No X-Exim-ID: 1qvSMO-001oyw-0H X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-21-192.static.axtel.net ([192.168.15.10]) [187.162.21.192]:48400 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 4 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNc0e/RwBpAQBjYT1fyF4PtyyvbOUUWvnhRJNHAxmQp3Gt9Vbuf6SVqg+Ua38enrEVE1S6Rp0f5wTFiJC3OpJrZ6V1bv0GfvcXDppm6i8NeZuj3nbuVt CEWVWg5F1R8HcNY/+3RQIwtYggPRPytJmReRwsH5rmtIldWgxa6opxX500OCWjBJY/rbKrpGqyI0ZiBkOM/dXXqs10YJRXwBbsgZNmJYawi4hz0DuJv/iEZF X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 18:10:27 -0700 (PDT) [+CC Manikanta Pubbisetty ] As Johannes[1] pointed out, this `memset()` is probably unnecessary: ./drivers/net/wireless/ath/ath10k/wmi.c: 8920 memset(skb->data, 0, sizeof(*cmd)); However, the same exact issue[2] is present at the line below inside function `ath10k_wmi_alloc_skb()`: drivers/net/wireless/ath/ath10k/wmi.c: 1799 memset(skb->data, 0, round_len); Thanks -- Gustavo [1] https://lore.kernel.org/linux-hardening/26b15f4702cef17fe70b496a62f03735874bd16a.camel@sipsolutions.net/ [2] https://lore.kernel.org/linux-hardening/07e9bb04-f9fc-46d5-bfb9-a00a63a707c0@embeddedor.com/ On 10/24/23 13:50, Gustavo A. R. Silva wrote: > Hi all, > > While working on tranforming one-element array `peer_chan_list` in > `struct wmi_tdls_peer_capabilities` into a flex-array member > > 7187 struct wmi_tdls_peer_capabilities { > ... > 7199         struct wmi_channel peer_chan_list[1]; > 7200 } __packed; > > the following line caught my attention: > > ./drivers/net/wireless/ath/ath10k/wmi.c: > 8920         memset(skb->data, 0, sizeof(*cmd)); > > Notice that before the flex-array transformation, we are zeroing 128 > bytes in `skb->data` because `sizeof(*cmd) == 128`, see below: > > $ pahole -C wmi_10_4_tdls_peer_update_cmd drivers/net/wireless/ath/ath10k/wmi.o > struct wmi_10_4_tdls_peer_update_cmd { >     __le32                     vdev_id;              /*     0     4 */ >     struct wmi_mac_addr        peer_macaddr;         /*     4     8 */ >     __le32                     peer_state;           /*    12     4 */ >     __le32                     reserved[4];          /*    16    16 */ >     struct wmi_tdls_peer_capabilities peer_capab;    /*    32    96 */ > >     /* size: 128, cachelines: 2, members: 5 */ > }; > > So, after the flex-array transformation (and the necessary adjustments > to a few other lines of code) we would be zeroing 104 bytes in > `skb->data` because `sizeof(*cmd) == 104`, see below: > > $ pahole -C wmi_10_4_tdls_peer_update_cmd drivers/net/wireless/ath/ath10k/wmi.o > struct wmi_10_4_tdls_peer_update_cmd { >     __le32                     vdev_id;              /*     0     4 */ >     struct wmi_mac_addr        peer_macaddr;         /*     4     8 */ >     __le32                     peer_state;           /*    12     4 */ >     __le32                     reserved[4];          /*    16    16 */ >     struct wmi_tdls_peer_capabilities peer_capab;    /*    32    72 */ > >     /* size: 104, cachelines: 2, members: 5 */ >     /* last cacheline: 40 bytes */ > }; > > This difference arises because the size of the element type for the > `peer_chan_list` array, which is `sizeof(struct wmi_channel) == 24 ` > > $ pahole -C wmi_channel drivers/net/wireless/ath/ath10k/wmi.o > struct wmi_channel { >     __le32                     mhz;                  /*     0     4 */ >     __le32                     band_center_freq1;    /*     4     4 */ >     __le32                     band_center_freq2;    /*     8     4 */ > > [..] >                                                /*    20     4 */ > >     /* size: 24, cachelines: 1, members: 6 */ >     /* last cacheline: 24 bytes */ > }; > > is included in `sizeof(*cmd)` before the transformation. > > So, my question is: do we really need to zero out those extra 24 bytes in > `skb->data`? or is it rather a bug in the original code? > > Thanks! > -- > Gustavo > >