bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Konovalov <andreyknvl@google.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Kees Cook <keescook@chromium.org>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Shuah Khan <shuah@kernel.org>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	"open list:KERNEL SELFTEST FRAMEWORK" 
	<linux-kselftest@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Dmitry Vyukov <dvyukov@google.com>,
	Kostya Serebryany <kcc@google.com>,
	Evgeniy Stepanov <eugenis@google.com>,
	Lee Smith <Lee.Smith@arm.com>,
	Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>,
	Jacob Bramley <Jacob.Bramley@arm.com>,
	Ruben Ayrapetyan <Ruben.Ayrapetyan@arm.com>,
	Chintan Pandya <cpandya@codeaurora.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	Dave Martin <Dave.Martin@arm.com>,
	Kevin Brodsky <kevin.brodsky@arm.com>,
	Szabolcs Nagy <Szabolcs.Nagy@arm.com>
Subject: Re: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive
Date: Tue, 19 Mar 2019 17:14:47 +0100	[thread overview]
Message-ID: <CAAeHK+xi4-6pgDYG8ypM8NsbhgncpsxgJeEXL1-BpkARXONvEQ@mail.gmail.com> (raw)
In-Reply-To: <CANn89iJ4SeccE79gKiv5RFqaouFV8shFA+0dCS8+2D_1aRq_Kw@mail.gmail.com>

On Mon, Mar 18, 2019 at 6:35 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Mon, Mar 18, 2019 at 10:18 AM Andrey Konovalov <andreyknvl@google.com> wrote:
> >
> > This patch is a part of a series that extends arm64 kernel ABI to allow to
> > pass tagged user pointers (with the top byte set to something else other
> > than 0x00) as syscall arguments.
> >
> > tcp_zerocopy_receive() uses provided user pointers for vma lookups, which
> > can only by done with untagged pointers.
> >
> > Untag user pointers in this function.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > ---
> >  net/ipv4/tcp.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> > index 6baa6dc1b13b..e76beb5ff1ff 100644
> > --- a/net/ipv4/tcp.c
> > +++ b/net/ipv4/tcp.c
> > @@ -1749,7 +1749,7 @@ EXPORT_SYMBOL(tcp_mmap);
> >  static int tcp_zerocopy_receive(struct sock *sk,
> >                                 struct tcp_zerocopy_receive *zc)
> >  {
> > -       unsigned long address = (unsigned long)zc->address;
> > +       unsigned long address;
> >         const skb_frag_t *frags = NULL;
> >         u32 length = 0, seq, offset;
> >         struct vm_area_struct *vma;
> > @@ -1758,7 +1758,12 @@ static int tcp_zerocopy_receive(struct sock *sk,
> >         int inq;
> >         int ret;
> >
> > -       if (address & (PAGE_SIZE - 1) || address != zc->address)
> > +       address = (unsigned long)untagged_addr(zc->address);
> > +
> > +       /* The second test in this if detects if the u64->unsigned long
> > +        * conversion had any truncated bits.
> > +        */
> > +       if (address & (PAGE_SIZE - 1) || address != untagged_addr(zc->address))
> >                 return -EINVAL;
> >
> >         if (sk->sk_state == TCP_LISTEN)
>
>
> This is quite ugly, the comment does not really help nor belong to this patch.
>
> What about using  untagged_addr()  only once ?
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 6baa6dc1b13b0b94b1da238668b93e167cf444fe..855a1f68c1ea9b0d07a92bd7f5e7c24840a99d3d
> 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1761,6 +1761,8 @@ static int tcp_zerocopy_receive(struct sock *sk,
>         if (address & (PAGE_SIZE - 1) || address != zc->address)
>                 return -EINVAL;
>
> +       address = untagged_addr(address);
> +
>         if (sk->sk_state == TCP_LISTEN)
>                 return -ENOTCONN;

Looks good, will do it like this in the next version. Thanks!

  reply	other threads:[~2019-03-19 16:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18 17:17 [PATCH v12 00/13] arm64: untag user pointers passed to the kernel Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 01/13] uaccess: add untagged_addr definition for other arches Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 02/13] arm64: untag user pointers in access_ok and __uaccess_mask_ptr Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 03/13] lib, arm64: untag user pointers in strn*_user Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 04/13] mm, arm64: untag user pointers passed to memory syscalls Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 05/13] mm, arm64: untag user pointers in mm/gup.c Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 06/13] fs, arm64: untag user pointers in copy_mount_options Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 07/13] fs, arm64: untag user pointers in fs/userfaultfd.c Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive Andrey Konovalov
2019-03-18 17:35   ` Eric Dumazet
2019-03-19 16:14     ` Andrey Konovalov [this message]
2019-03-18 17:17 ` [PATCH v12 09/13] kernel, arm64: untag user pointers in prctl_set_mm* Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 10/13] tracing, arm64: untag user pointers in seq_print_user_ip Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 11/13] uprobes, arm64: untag user pointers in find_active_uprobe Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 12/13] bpf, arm64: untag user pointers in stack_map_get_build_id_offset Andrey Konovalov
2019-03-18 17:17 ` [PATCH v12 13/13] selftests, arm64: add a selftest for passing tagged pointers to kernel Andrey Konovalov
2019-03-19 18:32 ` [PATCH v12 00/13] arm64: untag user pointers passed to the kernel Andrew Morton
2019-03-20 11:25   ` Catalin Marinas

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=CAAeHK+xi4-6pgDYG8ypM8NsbhgncpsxgJeEXL1-BpkARXONvEQ@mail.gmail.com \
    --to=andreyknvl@google.com \
    --cc=Dave.Martin@arm.com \
    --cc=Jacob.Bramley@arm.com \
    --cc=Lee.Smith@arm.com \
    --cc=Ramana.Radhakrishnan@arm.com \
    --cc=Ruben.Ayrapetyan@arm.com \
    --cc=Szabolcs.Nagy@arm.com \
    --cc=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=cpandya@codeaurora.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=eugenis@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kcc@google.com \
    --cc=keescook@chromium.org \
    --cc=kevin.brodsky@arm.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=robin.murphy@arm.com \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=vincenzo.frascino@arm.com \
    --cc=will.deacon@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).