Re: [RFC PATCH 0/4] net/io_uring: pass a kernel pointer via optlen_t to proto[_ops].getsockopt()
From: Linus Torvalds
Date: Wed Apr 02 2025 - 17:15:52 EST
On Wed, 2 Apr 2025 at 13:46, David Laight <david.laight.linux@xxxxxxxxx> wrote:
>
> The problem is that the generic code has to deal with all the 'wild stuff'.
> It is also common to do non-sequential accesses - so iov_iter doesn't match
> at all.
> There also isn't a requirement for scatter-gather.
Note that the generic code has special cases for the simple stuff,
which is all that the sockopt code would need.
Now, that's _particularly_ true for the "single user address range"
thing, where there's a special ITER_UBUF thing.
We don't actually have a "single kernel range" version of that, but
ITER_KVEC is simple to use, and the sockopt code could say "I only
ever look at the first buffer".
It's ok to just not handle all the cases, and you don't *have* to use
the generic "copy_from_iter()" routines if you don't want to.
In fact, I would expect that something like sockopt generally wouldn't
want to use the normal iter copying routines, since those are
basically all geared towards "copy and update the iter".
Linus