[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAeHK+xi4-6pgDYG8ypM8NsbhgncpsxgJeEXL1-BpkARXONvEQ@mail.gmail.com>
Date: Tue, 19 Mar 2019 17:14:47 +0100
From: Andrey Konovalov <andreyknvl@...gle.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Mark Rutland <mark.rutland@....com>,
Robin Murphy <robin.murphy@....com>,
Kees Cook <keescook@...omium.org>,
Kate Stewart <kstewart@...uxfoundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Shuah Khan <shuah@...nel.org>,
Vincenzo Frascino <vincenzo.frascino@....com>,
"David S. Miller" <davem@...emloft.net>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
linux-mm <linux-mm@...ck.org>,
linux-arch <linux-arch@...r.kernel.org>,
netdev <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Dmitry Vyukov <dvyukov@...gle.com>,
Kostya Serebryany <kcc@...gle.com>,
Evgeniy Stepanov <eugenis@...gle.com>,
Lee Smith <Lee.Smith@....com>,
Ramana Radhakrishnan <Ramana.Radhakrishnan@....com>,
Jacob Bramley <Jacob.Bramley@....com>,
Ruben Ayrapetyan <Ruben.Ayrapetyan@....com>,
Chintan Pandya <cpandya@...eaurora.org>,
Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
Dave Martin <Dave.Martin@....com>,
Kevin Brodsky <kevin.brodsky@....com>,
Szabolcs Nagy <Szabolcs.Nagy@....com>
Subject: Re: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive
On Mon, Mar 18, 2019 at 6:35 PM Eric Dumazet <edumazet@...gle.com> wrote:
>
> On Mon, Mar 18, 2019 at 10:18 AM Andrey Konovalov <andreyknvl@...gle.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@...gle.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!
Powered by blists - more mailing lists