All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Bobby Eshleman <bobbyeshleman@gmail.com>
Cc: Breno Leitao <leitao@debian.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Stefano Garzarella <sgarzare@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	sdf.kernel@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, virtualization@lists.linux.dev,
	linux-kselftest@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH net-next 2/3] vsock: convert to getsockopt_iter
Date: Fri, 1 May 2026 22:21:05 +0100	[thread overview]
Message-ID: <20260501222105.747dea59@pumpkin> (raw)
In-Reply-To: <afTjvM1P4gjPSvW8@devvm29614.prn0.facebook.com>

On Fri, 1 May 2026 10:32:44 -0700
Bobby Eshleman <bobbyeshleman@gmail.com> wrote:

> On Fri, May 01, 2026 at 08:52:52AM -0700, Breno Leitao wrote:
> > Convert AF_VSOCK's getsockopt implementation to use the new
> > getsockopt_iter callback with sockopt_t. The single
> > vsock_connectible_getsockopt() callback is shared by both
> > vsock_stream_ops and vsock_seqpacket_ops, so both proto_ops are
> > updated to use .getsockopt_iter.
> > 
> > Key changes:
> > - Replace (char __user *optval, int __user *optlen) with sockopt_t *opt
> > - Use opt->optlen for buffer length (input) and returned size (output)
> > - Use copy_to_iter() instead of put_user()/copy_to_user()
> > 
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > ---
> >  net/vmw_vsock/af_vsock.c | 16 +++++++---------
> >  1 file changed, 7 insertions(+), 9 deletions(-)
> > 
> > diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> > index 44037b066a5ff..d4a97eeb596e6 100644
> > --- a/net/vmw_vsock/af_vsock.c
> > +++ b/net/vmw_vsock/af_vsock.c
> > @@ -155,6 +155,7 @@
> >  #include <linux/random.h>
> >  #include <linux/skbuff.h>
> >  #include <linux/smp.h>
> > +#include <linux/uio.h>
> >  #include <linux/socket.h>
> >  #include <linux/stddef.h>
> >  #include <linux/sysctl.h>
> > @@ -2091,8 +2092,7 @@ static int vsock_connectible_setsockopt(struct socket *sock,
> >  
> >  static int vsock_connectible_getsockopt(struct socket *sock,
> >  					int level, int optname,
> > -					char __user *optval,
> > -					int __user *optlen)
> > +					sockopt_t *opt)
> >  {
> >  	struct sock *sk = sock->sk;
> >  	struct vsock_sock *vsk = vsock_sk(sk);
> > @@ -2110,8 +2110,7 @@ static int vsock_connectible_getsockopt(struct socket *sock,
> >  	if (level != AF_VSOCK)
> >  		return -ENOPROTOOPT;
> >  
> > -	if (get_user(len, optlen))
> > -		return -EFAULT;
> > +	len = opt->optlen;
> >  
> >  	memset(&v, 0, sizeof(v));
> >  
> > @@ -2142,11 +2141,10 @@ static int vsock_connectible_getsockopt(struct socket *sock,
> >  		return -EINVAL;
> >  	if (len > lv)
> >  		len = lv;
> > -	if (copy_to_user(optval, &v, len))
> > +	if (copy_to_iter(&v, len, &opt->iter_out) != len)

I'd wrap that as copy_to_sockopt(&v, len, opt).
or to make the edits easier: copy_to_sockopt(opt, &v, len).
Then if someone decides to change the implementation none of the call
sites need changing.

-- David

> >  		return -EFAULT;
> >  
> > -	if (put_user(len, optlen))
> > -		return -EFAULT;
> > +	opt->optlen = len;
> >  
> >  	return 0;
> >  }
> > @@ -2631,7 +2629,7 @@ static const struct proto_ops vsock_stream_ops = {
> >  	.listen = vsock_listen,
> >  	.shutdown = vsock_shutdown,
> >  	.setsockopt = vsock_connectible_setsockopt,
> > -	.getsockopt = vsock_connectible_getsockopt,
> > +	.getsockopt_iter = vsock_connectible_getsockopt,
> >  	.sendmsg = vsock_connectible_sendmsg,
> >  	.recvmsg = vsock_connectible_recvmsg,
> >  	.mmap = sock_no_mmap,
> > @@ -2653,7 +2651,7 @@ static const struct proto_ops vsock_seqpacket_ops = {
> >  	.listen = vsock_listen,
> >  	.shutdown = vsock_shutdown,
> >  	.setsockopt = vsock_connectible_setsockopt,
> > -	.getsockopt = vsock_connectible_getsockopt,
> > +	.getsockopt_iter = vsock_connectible_getsockopt,
> >  	.sendmsg = vsock_connectible_sendmsg,
> >  	.recvmsg = vsock_connectible_recvmsg,
> >  	.mmap = sock_no_mmap,
> > 
> > -- 
> > 2.52.0
> >   
> 
> Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
> 


  reply	other threads:[~2026-05-01 21:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01 15:52 [PATCH net-next 0/3] net: Convert AF_NETLINK and AF_VSOCK to getsockopt_iter API Breno Leitao
2026-05-01 15:52 ` [PATCH net-next 1/3] netlink: convert to getsockopt_iter Breno Leitao
2026-05-04 14:54   ` Stanislav Fomichev
2026-05-01 15:52 ` [PATCH net-next 2/3] vsock: " Breno Leitao
2026-05-01 17:32   ` Bobby Eshleman
2026-05-01 21:21     ` David Laight [this message]
2026-05-04 14:54   ` Stanislav Fomichev
2026-05-01 15:52 ` [PATCH net-next 3/3] net: selftests: add getsockopt_iter regression tests Breno Leitao
2026-05-01 17:17   ` Bobby Eshleman
2026-05-04 14:57   ` Stanislav Fomichev
2026-05-05  2:20 ` [PATCH net-next 0/3] net: Convert AF_NETLINK and AF_VSOCK to getsockopt_iter API patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260501222105.747dea59@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=bobbyeshleman@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf.kernel@gmail.com \
    --cc=sgarzare@redhat.com \
    --cc=shuah@kernel.org \
    --cc=virtualization@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.