From: Nick Desaulniers <ndesaulniers@google.com>
To: Kees Cook <kees@kernel.org>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Jakub Kicinski <kuba@kernel.org>,
"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, cferris@google.com,
android-llvm-dev@google.com
Subject: Re: [PATCH v2 1/2][next] UAPI: ethtool: Use __struct_group() in struct ethtool_link_settings
Date: Thu, 5 Dec 2024 08:49:41 -0800 [thread overview]
Message-ID: <Z1HZpe3WE5As8UAz@google.com> (raw)
In-Reply-To: <202411151215.B56D49E36@keescook>
On Fri, Nov 15, 2024 at 12:38:55PM -0800, Kees Cook wrote:
> On Tue, Nov 12, 2024 at 07:08:32PM -0600, Gustavo A. R. Silva wrote:
> >
> >
> > On 11/11/24 16:22, Gustavo A. R. Silva wrote:
> > >
> > >
> > > On 09/11/24 12:02, Jakub Kicinski wrote:
> > > > On Tue, 29 Oct 2024 15:55:35 -0600 Gustavo A. R. Silva wrote:
> > > > > Use the `__struct_group()` helper to create a new tagged
> > > > > `struct ethtool_link_settings_hdr`. This structure groups together
> > > > > all the members of the flexible `struct ethtool_link_settings`
> > > > > 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].
> > > >
> > > > Possibly a very noob question, but I'm updating a C++ library with
> > > > new headers and I think this makes it no longer compile.
> > > >
> > > > $ cat > /tmp/t.cpp<<EOF
> > > > extern "C" {
> > > > #include "include/uapi/linux/ethtool.h"
> > > > }
> > > > int func() { return 0; }
> > > > EOF
> > > >
> > > > $ g++ /tmp/t.cpp -I../linux -o /dev/null -c -W -Wall -O2
> > > > In file included from /usr/include/linux/posix_types.h:5,
> > > > from /usr/include/linux/types.h:9,
> > > > from ../linux/include/uapi/linux/ethtool.h:18,
> > > > from /tmp/t.cpp:2:
> > > > ../linux/include/uapi/linux/ethtool.h:2515:24: error: ‘struct
> > > > ethtool_link_settings::<unnamed union>::ethtool_link_settings_hdr’
> > > > invalid; an anonymous union may only have public non-static data
> > > > members [-fpermissive]
> > > > 2515 | __struct_group(ethtool_link_settings_hdr, hdr, /* no attrs */,
> > > > | ^~~~~~~~~~~~~~~~~~~~~~~~~
> > > >
> > > >
> >
> > This seems to work with Clang:
> >
> > $ clang++-18 -fms-extensions /tmp/t.cpp -I../linux -o /dev/null -c -W -Wall -O2
> >
> > However, `-fms-extensions` doesn't seem to work for this case with GCC:
> >
> > https://godbolt.org/z/1shsPhz3s
>
> Hm, we can't break UAPI even for C++, so even if we had compiler options
> that would make it work, it's really unfriendly to userspace to make all
> the projects there suddenly start needing to use it.
>
> I think this means we just can't use tagged struct groups in UAPI. :(
>
> I have what I think is a much simpler solution. Sending it now...
What was the follow up?
cferris@ is reporting something similar for linux/uapi/linux/pkt_cls.h in the
structure tc_u32_sel definition, found while updating the kernel headers in
Android. Maybe that file/definition needs the same follow up?
~Nick
next prev parent reply other threads:[~2024-12-05 16:49 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 [this message]
[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
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=Z1HZpe3WE5As8UAz@google.com \
--to=ndesaulniers@google.com \
--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=kees@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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).