From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5063A1DEFF3 for ; Mon, 28 Oct 2024 23:34:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.89.44.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730158476; cv=none; b=mCXiDKicPcyFG9EiNSErK0r2XRNs5boIbhvWDislh6hTCLEn6YmiOGbGNRKdHSYWY+kQeG0Jm77hni17qZ+vzy/VanXLtOlJZdYUzTGWOVlToZj38sm28tZNevzIsyNhCX6kr9A38y4q1KvgsZ+WrcN0e0fTZ8asxJIoX06EDdw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730158476; c=relaxed/simple; bh=RtCS7lHR0LRDRLoeU3O3Ly3LNOj3HoTC4oF3o/Mqe/Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GZmHeAo7Pa1EZXnMT1iO/MzNgMaAGtZS8W4aJastoIC7tHYJfsZ6bqWXkl+jOj6MGZdrk6JDQOMvxX0cCxLm9IiKJ2NL6vHniWBlEIWeEmEvQyrZ2Kw1Tn3GyErTpxnJP1Jr3GyURrVpGpo0sHn8tbia8ugQe6PZ902d5oGhUjs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com; spf=pass smtp.mailfrom=embeddedor.com; dkim=pass (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b=SVtJPMUi; arc=none smtp.client-ip=35.89.44.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=embeddedor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b="SVtJPMUi" Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id 5RyutxO4DVpzp5ZEItdagI; Mon, 28 Oct 2024 23:32:58 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id 5ZEHtNZZ5TqCN5ZEHtxydG; Mon, 28 Oct 2024 23:32:58 +0000 X-Authority-Analysis: v=2.4 cv=VsQlAf2n c=1 sm=1 tr=0 ts=67201f2a a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=OKg9RQrQ6+Y1xAlsUndU0w==:17 a=IkcTkHD0fZMA:10 a=DAUX931o1VcA:10 a=7T7KSl7uo7wA:10 a=GBAvCzrZPYQCsMOAwX0A:9 a=QEXdDO2ut3YA:10 a=Xt_RvD8W3m28Mn_h3AK8: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:From:References:Cc:To: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=BIzwlyyyd/IYUg64cRhgHObYnnTGPOZvFSvdyRlz/Ig=; b=SVtJPMUiBkyxbEICXAGC1WB77p ltlT2bB8Q/ganOZ5rEZdsKIVRYAajBo+rWitxazaNLsiicProME8XyldZEhlbOEfTAhvxr9Ty5Xr+ MdYrVdfm2e5zLVxV7We2F9dZA8nJlpfe9IDXqwIdATPXe3ljOGSeclUFtDV4WWLXaOaR8jwZ29U7h sbgARU7fiPbq/PlKddHCPh78nftlMb+nCx/dgHEsjGLA2FXcdYsEeMzBrJhdjSyYF2p9X43x+xMWd axWQJSIRJ+E0o2eTdMfFBEX5Qeda6iHvtlY6JINb4xVrYI4NqG9mnZqkT7EDCIgkZ6Ek5Kfia1SrI rOGBB56w==; Received: from [201.172.173.7] (port=34890 helo=[192.168.15.6]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1t5ZEF-003rjt-36; Mon, 28 Oct 2024 18:32:56 -0500 Message-ID: <158eb222-d875-4f96-b027-83854e5f4275@embeddedor.com> Date: Mon, 28 Oct 2024 17:32:53 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2][next] net: ethtool: Avoid thousands of -Wflex-array-member-not-at-end warnings To: Jakub Kicinski , "Gustavo A. R. Silva" Cc: Michael Chan , Andrew Lunn , "David S. Miller" , Eric Dumazet , Paolo Abeni , Potnuri Bharat Teja , Christian Benvenuti , Satish Kharat , Manish Chopra , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20241028162131.39e280bd@kernel.org> Content-Language: en-US From: "Gustavo A. R. Silva" In-Reply-To: <20241028162131.39e280bd@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: 201.172.173.7 X-Source-L: No X-Exim-ID: 1t5ZEF-003rjt-36 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.15.6]) [201.172.173.7]:34890 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 2 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGhcbeC7GlOIkGiwTnMjG6Q34R7KRU5fNWZOLsXjxb2G/vOQPqroY/dzNX+KaYrpey1nMIqshHYQKZ8OpC6qll3AHyivHe8uQHCp+A7Pv2P70ZhObMlD W18R++ERoATqHgZrXtQvoGw7jNzaVx3u4lnVHftdyG4Ob9iKdPI0ufHnVakxWhVyFNsYsQKFM7udaKuP++sXVAxWJsgdFjuWyfUVFTYt8mFJcnnwZsoCFBCi On 28/10/24 17:21, Jakub Kicinski wrote: > On Mon, 21 Oct 2024 13:02:27 -0600 Gustavo A. R. Silva wrote: >> Fix 3338 of the following -Wflex-array-member-not-at-end warnings: >> >> include/linux/ethtool.h:214:38: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] > > I don't see any change in the number of warnings with W=1: > gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3) > Is it only enabled with W=2? -Wfamnae is not currently part of any upstream build. We are working to have it enabled. So, these warnings are the ones I see in my local build with the following patch applied: diff --git a/Makefile b/Makefile index d4a41c44e0fc..08d18b5d01f5 100644 --- a/Makefile +++ b/Makefile @@ -1002,6 +1002,9 @@ NOSTDINC_FLAGS += -nostdinc # perform bounds checking. KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) +# Avoid flexible-array members not at the end of composite structure. +KBUILD_CFLAGS += $(call cc-option, -Wflex-array-member-not-at-end) + #Currently, disable -Wstringop-overflow for GCC 11, globally. KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow) KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow) > >> Additionally, update the type of some variables in various functions >> that don't access the flexible-array member, changing them to the >> newly created `struct ethtool_link_settings_hdr`. > > Why? Please avoid unnecessary code changes. This is actually necessary. As the type of the conflicting middle members changed, those instances that expect the type to be `struct ethtool_link_settings` should be adjusted to the new type. Another option is to leave the type unchanged and instead use container_of. See below. So, instead of this: - struct ethtool_link_settings *base = &link_ksettings->base; + struct ethtool_link_settings_hdr *base = &link_ksettings->base; we would do something like this: - struct ethtool_link_settings *base = &link_ksettings->base; + struct ethtool_link_settings *base = container_of(&link_ksettings->base, + struct struct ethtool_link_settings, hdr); I think that in this case, we could avoid using `container_of()`, but if you prefer that, I can update the patch. > >> include/linux/ethtool.h | 2 +- > > This is probably where most of the warnings come from. > Please split the changes to this header file as a separate patch > for ease of review / validation. > Sure thing! Thanks -- Gustavo