Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2116600rda; Tue, 24 Oct 2023 12:50:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9bZWMrVykAZdvakysXSmzv9kEj/liT73MSXn/MAiAdB40lu4nvYTEonnF/wjlPYnrowRR X-Received: by 2002:a17:902:e5c6:b0:1ca:e9f8:2ae7 with SMTP id u6-20020a170902e5c600b001cae9f82ae7mr9221549plf.0.1698177045232; Tue, 24 Oct 2023 12:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698177045; cv=none; d=google.com; s=arc-20160816; b=PByMWmxDhxkRPeQSwUCnxB1XO3uxY3MTfa16IEnXuCQj6iVlpJpiWLNfjUJQMJpdxB eY91vQqBg35yGQZHCVzawHSk58Q9sNzFeuWnKcAsHq98ypsZXlaE/AfV8PWJMcbawugI pn6iiy3qhYda8YOycdj+cIxh3oWtEe/b7nJqaxWtJ4yhTjgTvjHc96qpcz+gJzJJXzPR azTkJWq1LBDaOBRXjnDKJ/dMq1HV+1mdEc3rYcpsPWXmO+at9chFEcRYVtlS3/Qz3BRz Dc3xw3f1HaBV8fd7ixbVewreEYwGmADxhd7wXg/hoG6g6Qcw9HHz/NQNbHb5yH4SrdTw kezw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject:from :content-language:user-agent:mime-version:date:message-id :dkim-signature; bh=g54kz6I2OxMrqzBsVAyW+xfzdHVn9xE3lpEyC5lhvJs=; fh=lp2qATugHiMF2CuKGewqxJLTdM2vb0o0KwdB1f7G6Vw=; b=Z2ABlaDpLZSTCCCxG3wQF2SYMMavfxmgYJ/YE+LkKfojtC9ZANxkAAyY+onomlL0sa slIcQEcGPiuDzsPtETUO+XdoTKtkmoUlxNg0R3LlJlqVHOdNgVn0XOfh00av/EuHIVpb iwkcQU98bO/Jg3f5NDvhbFv9ji4n2541rCWGVckj9sVqGRF0BSbL2IqubUVFSSdjRv43 BE/cV0M8xcwXSwxocsZtyWDdz+O0qEzuT+CXhLg4ZqVYnMGYqlViC6AQB8exV7FJNo+d U4pIOALyeMALHfrmk5VeZTfH6ozajQ7qQfwd3/RNnmqBUyfggMPoNPPC8jzTEe044GQ9 RDzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=OzZcSIgm; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id p10-20020a170902e74a00b001c60a0a8d2asi8795166plf.282.2023.10.24.12.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 12:50:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=OzZcSIgm; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:8 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 339EA80212C5; Tue, 24 Oct 2023 12:50:41 -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 S1344218AbjJXTuk (ORCPT + 52 others); Tue, 24 Oct 2023 15:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234912AbjJXTuj (ORCPT ); Tue, 24 Oct 2023 15:50:39 -0400 Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A484122 for ; Tue, 24 Oct 2023 12:50:37 -0700 (PDT) Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id vLeIq63nYKOkLvNQCqmr6q; Tue, 24 Oct 2023 19:50:37 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id vNQBqvvsqF1O4vNQCqm6fx; Tue, 24 Oct 2023 19:50:36 +0000 X-Authority-Analysis: v=2.4 cv=CcwbWZnl c=1 sm=1 tr=0 ts=6538200c 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=uwMjjtW2jUbwP7mzfGYA:9 a=QEXdDO2ut3YA:10 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:Cc:To: Subject:From: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=g54kz6I2OxMrqzBsVAyW+xfzdHVn9xE3lpEyC5lhvJs=; b=OzZcSIgm+yEGFVLC3R0m8HijPQ lhLIjWcJvlYi/ttwdT02zDdt8r9JXRcveNlKlsLuW9I7KEx90YSSUkyBAJxIasNaoBw5eXEBqryHR TEfhawSfU7CSH/BkMqiMQyhXqNl3Fs58s+/XfkacYUo82q8kdpPPOM216HjPlf0GtmJqbFruaT5fA mznRgRxTTfbSlBfcUdwb5pu6XgiDLRHx80NEsNF0uQF9GT1UA8/CP4SAcN926YU7vwzs0IYOE5kaz qt6BR19MBBqj/VrGVPM93VlENWousMPGOcHUPdyW/6t60Vlk0T0YSHn9aFAImWY5q6MEKhderrafn iSBqr1TQ==; Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:48784 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 1qvNQB-001ZQp-1F; Tue, 24 Oct 2023 14:50:35 -0500 Message-ID: <626ae2e7-66f8-423b-b17f-e75c1a6d29b3@embeddedor.com> Date: Tue, 24 Oct 2023 13:50:34 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: "Gustavo A. R. Silva" Subject: [RFC - is this a bug?] wifi: ath10k: Asking for some light on this, please :) To: Kalle Valo , Jeff Johnson Cc: ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: 1qvNQB-001ZQp-1F 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]:48784 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: MS4xfJttZ0PKxoGfqXJ8U8HphXIdTU7GgySZE7jjOXfOi9SuQgAJX3AiDuKKIdostdO7KxsTTLSe4hpuTMzB3x34tOpG5gkPy48iQfG4tZseqDarJXd+ehPB Opv0Gs9uoe5Lt87t0MtuDn3t7n1xEHG/EzL1hEjiE02l13LqEAZNy5iwCehbnyHcnh5n7jIYWvK2ktpi7FnyBx5hIzljnNnD8u6yqua9AdGdthoHm9wqcvRv 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 12:50:41 -0700 (PDT) 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