Re: [PATCH net-next v3 0/4] net: move .getsockopt away from __user buffers (update 1)
From: David Laight <hidden>
Date: 2026-06-05 15:14:29
Also in:
bpf, io-uring, lkml
On Fri, 5 Jun 2026 05:25:21 -0700 Breno Leitao [off-list ref] wrote:
On Wed, Apr 08, 2026 at 03:30:28AM -0700, Breno Leitao wrote:quoted
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,
I'd have thought it would also have been better to use a wrapper function instead of direct calls to copy_from_iter(). There is no need for most of the code to know there is a iov_iter hiding inside sockopt_t. -- David
quoted
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@debian.org/ (local) 2) smc: Submitted today. This is only limited to UBUF right now https://lore.kernel.org/all/20260605-getsockopt_smc-v1-1-65da62fa44c4@debian.org/ (local) 3) CAN drivers: Reviewed and acked, pending Marc's merge https://lore.kernel.org/all/f83e25e1-b9f5-4810-bbd6-fdb8d2a10c8e@hartkopp.net/ (local) 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.