[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251023124043.3dab5646@pumpkin>
Date: Thu, 23 Oct 2025 12:40:43 +0100
From: David Laight <david.laight.linux@...il.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: Kees Cook <kees@...nel.org>, Jakub Kicinski <kuba@...nel.org>, "Gustavo
A. R. Silva" <gustavo@...eddedor.com>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, John Fastabend
<john.fastabend@...il.com>, "David S. Miller" <davem@...emloft.net>, Eric
Dumazet <edumazet@...gle.com>, Simon Horman <horms@...nel.org>, Kuniyuki
Iwashima <kuniyu@...gle.com>, Willem de Bruijn <willemb@...gle.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH v3 1/9] net: Add struct sockaddr_unspec for sockaddr of
unknown length
On Thu, 23 Oct 2025 12:43:06 +0200
Paolo Abeni <pabeni@...hat.com> wrote:
> On 10/20/25 11:26 PM, Kees Cook wrote:
> > Add flexible sockaddr structure to support addresses longer than the
> > traditional 14-byte struct sockaddr::sa_data limitation without
> > requiring the full 128-byte sa_data of struct sockaddr_storage. This
> > allows the network APIs to pass around a pointer to an object that
> > isn't lying to the compiler about how big it is, but must be accompanied
> > by its actual size as an additional parameter.
> >
> > It's possible we may way to migrate to including the size with the
> > struct in the future, e.g.:
> >
> > struct sockaddr_unspec {
> > u16 sa_data_len;
> > u16 sa_family;
> > u8 sa_data[] __counted_by(sa_data_len);
> > };
>
> Side note: sockaddr_unspec is possibly not the optimal name, as
> AF_UNSPEC has a specific meaning/semantic.
>
> Name-wise, I think 'sockaddr_sized' would be better,
Or even sockaddr_unsized ?
> but I agree with David the struct may cause unaligned access problems.
It probably also wants the 'sized_by' attribute rather than 'counted_by'.
So wherever the length is saved it is the length the user supplied
for the structure (or the sizeof the protocol-specific one).
David
>
> /P
>
>
Powered by blists - more mailing lists