Subject: Re: [PATCH net-next v3 0/4] net: move .getsockopt away from __user buffers

From: David Laight <[email-masked]>
Date: Fri, 10 Apr 2026 15:15:20 +0100

On Fri, 10 Apr 2026 05:29:37 -0700
Breno Leitao <[email-masked]> wrote:

...
> Since these legacy protocols represent less than 1% of the cases, I'd prefer to
> optimize for the common path and handle the exceptional cases as exceptions.

Optimising for the common path would pass a fixed size on-stack buffer
(say 64 bytes - or perhaps enough for an IPv6 address) through to the protocol
code, update it, and do the copy_to_user() in the system call stub.
Write to small constant offsets onto the buffer could then just be direct
assignments through some pointer.

The 'buffer descriptor' would need to contain any associated user address for
the unusual cases (also look at the sctp socket options).

But I still think you need functions that read/write at offsets into
the buffer rather than using iov_iter - which is only really designed
for sequential access. It isn't as though you need scatter-gather.

	David