All of lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
	sdf@google.com, axboe@kernel.dk, asml.silence@gmail.com,
	martin.lau@linux.dev, krisman@suse.de, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	io-uring@vger.kernel.org, pabeni@redhat.com
Subject: Re: [PATCH v4 00/10] io_uring: Initial support for {s,g}etsockopt commands
Date: Mon, 9 Oct 2023 06:28:00 -0700	[thread overview]
Message-ID: <ZSP/4GVaQiFuDizz@gmail.com> (raw)
In-Reply-To: <CAF=yD-Lr3238obe-_omnPBvgdv2NLvdK5be-5F7YyV3H7BkhSg@mail.gmail.com>

On Mon, Oct 09, 2023 at 03:11:05AM -0700, Willem de Bruijn wrote:
> On Fri, Oct 6, 2023 at 10:45 AM Breno Leitao <leitao@debian.org> wrote:
> > Let me first back up and state where we are, and what is the current
> > situation:
> >
> > 1) __sys_getsockopt() uses __user pointers for both optval and optlen
> > 2) For io_uring command, Jens[1] suggested we get optlen from the io_uring
> > sqe, which is a kernel pointer/value.
> >
> > Thus, we need to make the common code (callbacks) able to handle __user
> > and kernel pointers (for optlen, at least).
> >
> > From a proto_ops callback perspective, ->setsockopt() uses sockptr.
> >
> >           int             (*setsockopt)(struct socket *sock, int level,
> >                                         int optname, sockptr_t optval,
> >                                         unsigned int optlen);
> >
> > Getsockopt() uses sockptr() for level=SOL_SOCKET:
> >
> >         int sk_getsockopt(struct sock *sk, int level, int optname,
> >                     sockptr_t optval, sockptr_t optlen)
> >
> > But not for the other levels:
> >
> >         int             (*getsockopt)(struct socket *sock, int level,
> >                                       int optname, char __user *optval, int __user *optlen);
> >
> >
> > That said, if this patchset shouldn't use sockptr anymore, what is the
> > recommendation?
> >
> > If we move this patchset to use iov_iter instead of sockptr, then I
> > understand we want to move *all* these callbacks to use iov_vec. Is this
> > the right direction?
> >
> > Thanks for the guidance!
> >
> > [1] https://lore.kernel.org/all/efe602f1-8e72-466c-b796-0083fd1c6d82@kernel.dk/
> 
> Since sockptr_t is already used by __sys_setsockopt and
> __sys_setsockopt, patches 1 and 2 don't introduce any new sockptr code
> paths.
> 
> setsockopt callbacks also already use sockptr as of commit
> a7b75c5a8c41 ("net: pass a sockptr_t into ->setsockopt").
> 
> getsockopt callbacks do take user pointers, just not sockptr.
> 
> Is the only issue right now the optlen kernel pointer?

Correct. The current discussion is only related to optlen in the
getsockopt() callbacks (invoked when level != SOL_SOCKET). Everything
else (getsockopt(level=SOL_SOCKET..) and setsockopt) is using sockptr.

Is it bad if we review/merge this code as is (using sockptr), and start
the iov_iter/getsockopt() refactor in a follow-up thread?

Thanks!

  reply	other threads:[~2023-10-09 13:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 16:24 [PATCH v4 00/10] io_uring: Initial support for {s,g}etsockopt commands Breno Leitao
2023-09-04 16:24 ` [PATCH v4 01/10] bpf: Leverage sockptr_t in BPF getsockopt hook Breno Leitao
2023-09-04 16:24 ` [PATCH v4 02/10] bpf: Leverage sockptr_t in BPF setsockopt hook Breno Leitao
2023-09-04 16:24 ` [PATCH v4 03/10] net/socket: Break down __sys_setsockopt Breno Leitao
2023-09-04 16:24 ` [PATCH v4 04/10] net/socket: Break down __sys_getsockopt Breno Leitao
2023-09-05  9:36   ` David Laight
2023-09-05 10:29   ` Andy Shevchenko
2023-09-04 16:24 ` [PATCH v4 05/10] io_uring/cmd: Pass compat mode in issue_flags Breno Leitao
2023-09-04 16:24 ` [PATCH v4 06/10] selftests/net: Extract uring helpers to be reusable Breno Leitao
2023-09-04 16:25 ` [PATCH v4 07/10] io_uring/cmd: return -EOPNOTSUPP if net is disabled Breno Leitao
2023-09-05 12:32   ` Gabriel Krisman Bertazi
2023-09-08 17:04     ` Breno Leitao
2023-09-04 16:25 ` [PATCH v4 08/10] io_uring/cmd: Introduce SOCKET_URING_OP_GETSOCKOPT Breno Leitao
2023-09-05 12:24   ` Gabriel Krisman Bertazi
2023-09-04 16:25 ` [PATCH v4 09/10] io_uring/cmd: Introduce SOCKET_URING_OP_SETSOCKOPT Breno Leitao
2023-09-05 12:24   ` Gabriel Krisman Bertazi
2023-09-04 16:25 ` [PATCH v4 10/10] selftests/bpf/sockopt: Add io_uring support Breno Leitao
2023-09-05 22:49 ` [PATCH v4 00/10] io_uring: Initial support for {s,g}etsockopt commands Jakub Kicinski
2023-09-08 16:55   ` Breno Leitao
2023-10-06 15:45   ` Breno Leitao
2023-10-09 10:11     ` Willem de Bruijn
2023-10-09 13:28       ` Breno Leitao [this message]
2023-10-09 16:55         ` Jakub Kicinski

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=ZSP/4GVaQiFuDizz@gmail.com \
    --to=leitao@debian.org \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=krisman@suse.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /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.