[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202410281637.8CF1EA8AE7@keescook>
Date: Mon, 28 Oct 2024 16:40:16 -0700
From: Kees Cook <kees@...nel.org>
To: Johannes Berg <johannes@...solutions.net>
Cc: Andrew Lunn <andrew@...n.ch>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Andrew Lunn <andrew+netdev@...n.ch>,
David Ahern <dsahern@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org, Simon Horman <horms@...nel.org>
Subject: Re: [PATCH v2 1/4][next] uapi: socket: Introduce struct
sockaddr_legacy
On Mon, Oct 28, 2024 at 09:47:08PM +0100, Johannes Berg wrote:
> On Mon, 2024-10-28 at 21:38 +0100, Andrew Lunn wrote:
> > > As this new struct will live in UAPI, to avoid breaking user-space code
> > > that expects `struct sockaddr`, the `__kernel_sockaddr_legacy` macro is
> > > introduced. This macro allows us to use either `struct sockaddr` or
> > > `struct sockaddr_legacy` depending on the context in which the code is
> > > used: kernel-space or user-space.
> >
> > Are there cases of userspace API structures where the flexiable array
> > appears in the middle?
>
> Clearly, it's the case for all the three other patches in this series.
The issue is that the kernel uses these structures, and the kernel's view
of sockaddr is that it (correctly) has a flexible array. Userspace's view
of sockaddr is the old struct (which comes from the libc, not the kernel)
which ends with a fake flexible array. We need to correct the kernel's
view of these structures to use the introduced legacy struct to avoid
lying to the compiler about what's going on. :)
--
Kees Cook
Powered by blists - more mailing lists