From patchwork Tue Aug 13 22:15:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13762615 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A45F91AAE39; Tue, 13 Aug 2024 22:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723587306; cv=none; b=kiHiUd9+h+pZJUN+MXyEcfw3hm8fxiL1o4M0fcKtGVJuAmVr5f5Txg7j8SKHn4NcANLNLz70+vqgLurk4A86iYdLbBe1M8niMtBqNvwkDmwcrU7YnOAJOic2VGzf4Wkc3fKQsW0vqBtlSdi9EemAxGZMbE2E4r/34iZS+xRnS38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723587306; c=relaxed/simple; bh=vt6nsaewShD5afhtTMqHJ1S+APpB3N3wBMEHbNW3qUc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dPbHhdIQ955MlBwdPBUrb14vNSV9gp/W8kgCaj/M1XZPBIMALEfjZclApsF6dYkdP3x/6gyP9ZSnfsbEUnUIWS+e84QTZHIglGk9L+uvwyl33wwRmCYJdxO0ipB74YOFokLebPsk7cY+yTls289lFGEFkrDhoxnxqzc9bM+wO94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U+I2LiXd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U+I2LiXd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE195C32782; Tue, 13 Aug 2024 22:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723587306; bh=vt6nsaewShD5afhtTMqHJ1S+APpB3N3wBMEHbNW3qUc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U+I2LiXdxJ76KzfaGzu8o11VOrCk3Ib4xUrt0mhb+mfRGCammi1tl7M/cpfDgRRP6 kBKB/gODwylm/C3TY7hsdjP8Rr8huvrJtZ5AIuU1L+mv0Ef82M+scNjn2cTiapiBad OAx8Tfk1z3tFeW5AiVeP+9EUT50rONMvpPagRXLDaAeNelgpVUUX0mTXORRaBwBadD onQwzkncA4HPPX464R8dVQIOXB8TcnmpmkKu+IwaxUcB8sv0ibIeen6YcUBET8dvd5 vL08YO3RAHpQ7ik0U9zjpl4LbHVPJcD3mLXVdPMC5WQgsx/QsQeY8OFqRvHB1Ib957 h0HEOQj0rhsAg== Date: Tue, 13 Aug 2024 16:15:02 -0600 From: "Gustavo A. R. Silva" To: Jamal Hadi Salim , Cong Wang , Jiri Pirko , Potnuri Bharat Teja , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH 1/2][next] UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Use the `__struct_group()` helper to create a new tagged `struct tc_u32_sel_hdr`. This structure groups together all the members of the flexible `struct tc_u32_sel` except the flexible array. As a result, the array is effectively separated from the rest of the members without modifying the memory layout of the flexible structure. This new tagged struct will be used to fix problematic declarations of middle-flex-arrays in composite structs[1]. [1] https://git.kernel.org/linus/d88cabfd9abc Signed-off-by: Gustavo A. R. Silva --- include/uapi/linux/pkt_cls.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index d36d9cdf0c00..2c32080416b5 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -246,16 +246,19 @@ struct tc_u32_key { }; struct tc_u32_sel { - unsigned char flags; - unsigned char offshift; - unsigned char nkeys; - - __be16 offmask; - __u16 off; - short offoff; - - short hoff; - __be32 hmask; + /* New members MUST be added within the __struct_group() macro below. */ + __struct_group(tc_u32_sel_hdr, hdr, /* no attrs */, + unsigned char flags; + unsigned char offshift; + unsigned char nkeys; + + __be16 offmask; + __u16 off; + short offoff; + + short hoff; + __be32 hmask; + ); struct tc_u32_key keys[]; }; From patchwork Tue Aug 13 22:15:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13762616 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 072F016BE34; Tue, 13 Aug 2024 22:15:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723587335; cv=none; b=OX/9yCJkiLZ28GcJInwXQtSWoSu9dOukhgjzeBpN9XL5lruEqnI6ui1OZFmf1eCDSVk+2vO3Vt/WsZGpocRsPiCCauMzWp6Z1hbKNJi2e45tI/j48r80PTykolNsWyGfshQM1TXK4SmlLdiK190VBAPKyCm+dCODO7kzvGgCpco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723587335; c=relaxed/simple; bh=FYHaFzOiFxZuIxjj47094gz6uizuqz/cvG1pwVG5PDY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DS8OnctJ3w5c9TQeNB6WAYw5/SFU2FknVEhf6spvVitXgCvoL+y8NbUsLIMga6PxtUbQT+KidvE+73o3JYPFK7r0g+lJB7NccYRL3T2KXAR9PgU3GE7jQyoBW5kzVsHSOAJ58fzTNvH81ngCzRJ5RZUecBvKs6swUfE4u8yt5lU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tCobg8HD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tCobg8HD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BCE6C32782; Tue, 13 Aug 2024 22:15:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723587334; bh=FYHaFzOiFxZuIxjj47094gz6uizuqz/cvG1pwVG5PDY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tCobg8HDDH9fxzTE7orSj2xZj4bM0/pXAD4Dmq1SlOIPNP/O9uen29q4aEE0RzWxR 5gNKBZcJJnYcMDLiIg8v/xzWuDsqhMoXctXildp4v/E9AyHzIH8PpK+bSvdaRgGjuZ fSHS5Y8WIUWk54JyyI4IdFOIpTu8HVeH+9XZlM87m8FCcPh8vO6pVwDfuXZHfgtdlP fRJWg2vKM2iri9BfsFD0ie+UVhd9iiiUkPCIQLBx8z/H+LMsHOxfkbheyAHnQBuHIL tirMbZyTkdkH6QoAF/du62DLJVRXAqKLY/7VeMgF6LFktnKcfqjdqZBXlnWwt+B2yl yzASHUtFuQAMQ== Date: Tue, 13 Aug 2024 16:15:31 -0600 From: "Gustavo A. R. Silva" To: Jamal Hadi Salim , Cong Wang , Jiri Pirko , Potnuri Bharat Teja , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH 2/2][next] cxgb4: Avoid -Wflex-array-member-not-at-end warning Message-ID: <97388e8a7990975aa56cf0ada211764c735c3432.1723586870.git.gustavoars@kernel.org> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org -Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally. Change the type of the middle struct member currently causing trouble from `struct tc_u32_sel` to `struct tc_u32_sel_hdr`. Fix the following warning: drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:245:27: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Signed-off-by: Gustavo A. R. Silva --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h index 9050568a034c..64663112cad8 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h @@ -242,7 +242,7 @@ struct cxgb4_next_header { * field's value to jump to next header such as IHL field * in IPv4 header. */ - struct tc_u32_sel sel; + struct tc_u32_sel_hdr sel; struct tc_u32_key key; /* location of jump to make */ const struct cxgb4_match_field *jump;