Re: [PATCH net-next v3 0/4] net: move .getsockopt away from __user buffers (update 1)
From: Breno Leitao
Date: Fri Jun 05 2026 - 08:36:04 EST
On Wed, Apr 08, 2026 at 03:30:28AM -0700, Breno Leitao wrote:
> Currently, the .getsockopt callback requires __user pointers:
>
> int (*getsockopt)(struct socket *sock, int level,
> int optname, char __user *optval, int __user *optlen);
>
> This prevents kernel callers (io_uring, BPF) from using getsockopt on
> levels other than SOL_SOCKET, since they pass kernel pointers.
>
> Following Linus' suggestion [0], this series introduces sockopt_t, a
> type-safe wrapper around iov_iter, and a getsockopt_iter callback that
> works with both user and kernel buffers. AF_PACKET and CAN raw are
> converted as initial users, with selftests covering the trickiest
> conversion patterns.
Quick update on this effort.
All proto_ops users have been converted to getsockopt_iter and submitted.
Most conversions are already in linux-next. Three remain:
1) rds: Under review
https://lore.kernel.org/all/20260605-getsock_more-v2-3-80f38cdb8706@xxxxxxxxxx/
2) smc: Submitted today. This is only limited to UBUF right now
https://lore.kernel.org/all/20260605-getsockopt_smc-v1-1-65da62fa44c4@xxxxxxxxxx/
3) CAN drivers: Reviewed and acked, pending Marc's merge
https://lore.kernel.org/all/f83e25e1-b9f5-4810-bbd6-fdb8d2a10c8e@xxxxxxxxxxxx/
Once these are merged, I'll rename getsockopt_iter to getsockopt and
remove the legacy path.
Next, I'll convert struct proto the same way to eliminate the remaining
userspace optlen/optval pointers.
After that, io_uring getsockopt operations will be unblocked.