All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Christopher Ferris <cferris@google.com>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Michael Chan <michael.chan@broadcom.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Potnuri Bharat Teja <bharat@chelsio.com>,
	Christian Benvenuti <benve@cisco.com>,
	Satish Kharat <satishkh@cisco.com>,
	Manish Chopra <manishc@marvell.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org, android-llvm-dev@google.com
Subject: Re: [PATCH v2 1/2][next] UAPI: ethtool: Use __struct_group() in struct ethtool_link_settings
Date: Thu, 12 Dec 2024 09:29:02 -0800	[thread overview]
Message-ID: <202412120927.943DFEDD@keescook> (raw)
In-Reply-To: <CANtHk4nyP8HyYMobB76z9LpbA_jD=fLkWtyK9w_aMkzP8iB7Cg@mail.gmail.com>

On Mon, Dec 09, 2024 at 04:39:38PM -0800, Christopher Ferris wrote:
> By the way, there are some places where __struct_group is used in other
> uapi headers, the only difference is that the TAG field of the macro is
> left empty. That compiles fine when used in C++ code.

Does this fix the C++ inclusion for you?


diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 2c32080416b5..aeff841c528d 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -245,20 +245,27 @@ struct tc_u32_key {
 	int		offmask;
 };
 
+#define tc_u32_sel_hdr_members			\
+	unsigned char		flags;		\
+	unsigned char		offshift;	\
+	unsigned char		nkeys;		\
+	__be16			offmask;	\
+	__u16			off;		\
+	short			offoff;		\
+	short			hoff;
+
+struct tc_u32_sel_hdr {
+	tc_u32_sel_hdr_members
+};
+
 struct tc_u32_sel {
-	/* 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;
-	);
+	/* Open-coded struct_group() to avoid C++ errors. */
+	union {
+		struct tc_u32_sel_hdr hdr;
+		struct {
+			tc_u32_sel_hdr_members
+		};
+	};
 	struct tc_u32_key	keys[];
 };
 


-- 
Kees Cook

  parent reply	other threads:[~2024-12-12 17:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29 21:55 [PATCH v2 0/2][next] UAPI: net/ethtool: Avoid thousands of -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2024-10-29 21:55 ` [PATCH v2 1/2][next] UAPI: ethtool: Use __struct_group() in struct ethtool_link_settings Gustavo A. R. Silva
2024-11-09 18:02   ` Jakub Kicinski
2024-11-09 18:49     ` Jakub Kicinski
2024-11-11 22:22     ` Gustavo A. R. Silva
2024-11-13  1:08       ` Gustavo A. R. Silva
2024-11-15 20:38         ` Kees Cook
2024-12-05 16:49           ` Nick Desaulniers
     [not found]             ` <CANtHk4mnjE5aATk2r8uOsyLKm+7-tbEv5AaXVWGP_unhLNEvsg@mail.gmail.com>
2024-12-09 21:10               ` Jakub Kicinski
     [not found]                 ` <CANtHk4kM-9BDCm69+z3hS58uCrjCmma0aQ+nOqFUROaFhLAkDg@mail.gmail.com>
2024-12-09 21:39                   ` Gustavo A. R. Silva
     [not found]                     ` <CANtHk4nyP8HyYMobB76z9LpbA_jD=fLkWtyK9w_aMkzP8iB7Cg@mail.gmail.com>
2024-12-12 17:29                       ` Kees Cook [this message]
2024-10-29 21:58 ` [PATCH v2 2/2][next] net: ethtool: Avoid thousands of -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2024-11-03 19:20 ` [PATCH v2 0/2][next] UAPI: net/ethtool: " patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202412120927.943DFEDD@keescook \
    --to=kees@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=android-llvm-dev@google.com \
    --cc=benve@cisco.com \
    --cc=bharat@chelsio.com \
    --cc=cferris@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manishc@marvell.com \
    --cc=michael.chan@broadcom.com \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=satishkh@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.