Re: [PATCH net-next v3 0/4] net: move .getsockopt away from __user buffers
From: David Laight
Date: Fri Apr 10 2026 - 10:16:58 EST
On Fri, 10 Apr 2026 05:29:37 -0700
Breno Leitao <leitao@xxxxxxxxxx> 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