From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E772C43381 for ; Mon, 18 Mar 2019 17:35:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA92920854 for ; Mon, 18 Mar 2019 17:35:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uyrIqaY7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727455AbfCRRf3 (ORCPT ); Mon, 18 Mar 2019 13:35:29 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:52484 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbfCRRf2 (ORCPT ); Mon, 18 Mar 2019 13:35:28 -0400 Received: by mail-it1-f193.google.com with SMTP id g17so21752081ita.2 for ; Mon, 18 Mar 2019 10:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PrCO2lU0ZipPiiy31J0umfmtEn4o5iLh0G0tXGxKdqM=; b=uyrIqaY7oC9B9nG/UxXrp2razNOLtRgLgzTki3DkPSo3hKZBihhOVs5XMPl0tSTbG9 8BkxMAekwOpEr5c18J94vX/PHkd/cR8S37JaGiHv2rHoQtCm8VN0JQT4bVDxL4DnFuaf TBpB7mtD1xZMSM6CEOwzN6ylMmjBtpj/81knOnGPRXtUhR49sy3r7rujNqeJpemmcNe/ yahcAmwycILMB5vkZoN8PLSOFNCEEoAnrHt4dlbEmOy7anc6ZJcANenVW5WZHg63bVhQ EDhXKW0Z+zXP/J6GAQ7GCYiiP+UrBe+V732dR9WdPtz9JuQLQBUDqkDSRPo5Tqt0+iTo c1OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PrCO2lU0ZipPiiy31J0umfmtEn4o5iLh0G0tXGxKdqM=; b=ZCC0lOLfzDe6n8LjK5jlxQv0VeECacwF+cf4K8hhnHgWpZiIvBdUCk3nj7iVJlmakD 65Ugjd0nqd+Ns/V7sO/04NRhBhoAwZCcz+DfjT3fxHFokBi3IDSTJ5Uuyu/JAxsiXN9s mvUTFhpd1JmZ9CNht+WzgPsRX2k+t1KLhUrCfymJxT8ROaoD+ZNJx9JCBXQE+9ao9V/M F6B2tFxEP6jRNh07FdkN4f4Q/dDH6ljCqpiw22Utz3/zlksTXGfNciAQImo1Nkrf2N8k 36x7FHNRRiHFPQTYlSDWn/alrdpFLk35PDijtVv3NuRF9oN475zV/2QAPOmkmjJcbjgZ UyYg== X-Gm-Message-State: APjAAAWtgrPpAKOjev3tdgLYrMcS7era2XJqWrX5gbJcpMabySoN5GBx pJUwDCEphcbiMmtkXEa/v1iA3RcphMD8noNnD9W+HA== X-Google-Smtp-Source: APXvYqw7xww6FQki8SuPZw8IxP5jWoWikBVhp58R4A7DMUEMPaLunFv8UC7JQGZkd4Yza/sj1u2HgqSyKYRRdWhydLY= X-Received: by 2002:a05:660c:842:: with SMTP id f2mr25940itl.142.1552930526937; Mon, 18 Mar 2019 10:35:26 -0700 (PDT) MIME-Version: 1.0 References: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> In-Reply-To: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> From: Eric Dumazet Date: Mon, 18 Mar 2019 10:35:14 -0700 Message-ID: Subject: Re: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive To: Andrey Konovalov Cc: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Linux ARM , "open list:DOCUMENTATION" , linux-mm , linux-arch , netdev , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , LKML , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 18, 2019 at 10:18 AM Andrey Konovalov 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 > --- > 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; From mboxrd@z Thu Jan 1 00:00:00 1970 From: edumazet at google.com (Eric Dumazet) Date: Mon, 18 Mar 2019 10:35:14 -0700 Subject: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive In-Reply-To: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> References: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> Message-ID: On Mon, Mar 18, 2019 at 10:18 AM Andrey Konovalov 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 > --- > 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; From mboxrd@z Thu Jan 1 00:00:00 1970 From: edumazet@google.com (Eric Dumazet) Date: Mon, 18 Mar 2019 10:35:14 -0700 Subject: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive In-Reply-To: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> References: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> Message-ID: Content-Type: text/plain; charset="UTF-8" Message-ID: <20190318173514.-jpmxx7sIaRHKSFj_uzlKh6Ooi2xCoc-LauNL-OA3zE@z> On Mon, Mar 18, 2019@10:18 AM Andrey Konovalov 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 > --- > 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; From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive Date: Mon, 18 Mar 2019 10:35:14 -0700 Message-ID: References: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> Sender: linux-kernel-owner@vger.kernel.org To: Andrey Konovalov Cc: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo List-Id: linux-arch.vger.kernel.org On Mon, Mar 18, 2019 at 10:18 AM Andrey Konovalov 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 > --- > 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; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it1-f195.google.com ([209.85.166.195]:39074 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726835AbfCRRf2 (ORCPT ); Mon, 18 Mar 2019 13:35:28 -0400 Received: by mail-it1-f195.google.com with SMTP id l15so22624658iti.4 for ; Mon, 18 Mar 2019 10:35:27 -0700 (PDT) MIME-Version: 1.0 References: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> In-Reply-To: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> From: Eric Dumazet Date: Mon, 18 Mar 2019 10:35:14 -0700 Message-ID: Subject: Re: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive Content-Type: text/plain; charset="UTF-8" Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andrey Konovalov Cc: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Linux ARM , "open list:DOCUMENTATION" , linux-mm , linux-arch , netdev , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , LKML , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy Message-ID: <20190318173514.wTBgjgW2jzi5LZlPnTPDhOHHpLqgJt5VmYGWie0baA8@z> On Mon, Mar 18, 2019 at 10:18 AM Andrey Konovalov 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 > --- > 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; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3D41C43381 for ; Mon, 18 Mar 2019 17:35:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 93C4D20854 for ; Mon, 18 Mar 2019 17:35:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uyrIqaY7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93C4D20854 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 25AB96B0003; Mon, 18 Mar 2019 13:35:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E48D6B0006; Mon, 18 Mar 2019 13:35:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 089846B0007; Mon, 18 Mar 2019 13:35:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) by kanga.kvack.org (Postfix) with ESMTP id D281D6B0003 for ; Mon, 18 Mar 2019 13:35:28 -0400 (EDT) Received: by mail-it1-f200.google.com with SMTP id r136so15189149ith.3 for ; Mon, 18 Mar 2019 10:35:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:mime-version:references :in-reply-to:from:date:message-id:subject:to:cc; bh=PrCO2lU0ZipPiiy31J0umfmtEn4o5iLh0G0tXGxKdqM=; b=V6hH4xb9igaeREu4XdJry8frPGCUytIIPp86u2/44/cMEvqOWhY5lgT/ZCUqp+h4YI T//eGp2m4iW/mvnESgU7neRUa6iNi8TZmx8bYWK2iEb/+z2M8kjJndhNtLnxPRYB/Ur6 bzRLriCsmZSzjzgHcg8NZzsMWmR2j9x1RLpDTKX5PsiJyGuPfTPwrGOD/Cd5AH6MFr8y YfrCzEGAtUGaqfPTVcBi1vcWFxzNLDGPSVDb48cqW/5fg2cHDt4m2w3wLL1bAbI5j0s7 PLJUjE90x8mA8Nn1QXJu9RhTqeNAZqNQPGnah8kHVv+TNk5n79H/8uyjpdxb2cZWuM2M FNxQ== X-Gm-Message-State: APjAAAX6mY8lWUN1pZ3fAnsxT2lbgXQNl8qlVWAu1ogNbuXzyXfEdWFY i87a+w2sHh6jvSp1CTY4/tek8Cu0kPB5Vcodyqr2gUI9DUU5SHapbRAHwpQBy7E6iVfWLstqRT+ XPB4j6VAy2kEarBienM8j5Bq/JikgvKrjSKqRJf01wkeMlR1r1TDSxuUS/+Mkllfk9Q== X-Received: by 2002:a24:39d8:: with SMTP id l207mr9244ita.59.1552930528580; Mon, 18 Mar 2019 10:35:28 -0700 (PDT) X-Received: by 2002:a24:39d8:: with SMTP id l207mr9210ita.59.1552930527643; Mon, 18 Mar 2019 10:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552930527; cv=none; d=google.com; s=arc-20160816; b=BywBb1c3g6oObBqgyE32pun4RauZ/L6J9wl2Z1oeaS+Rg6f3njoVqjTIDOPNRUAww9 Ssnt3ncYQ1XXG43LA4h8gI7krqqg7TmOkIC/+fuP5hG5Ht5wJsNBtpFN6LShLHRFnW/2 KB9hHaZtWHkfprUWWh61TEsKR2UbGMY+xm1ytq5y1u3h6+NtZBWJqNQT9tWCoitqW3g7 OyC5n7e24M4kfEQxN2VSI+4LaAX+4OTzOBzfSyxpyL9/cMgvJ3BqTELBiO2kQFUWmo3p EZwTIC4HnCxTFccQDRv0+BMqHFLPxuriku/uUSI/4YteSyUnzVul9sctey87P1GSb1+N cz9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=PrCO2lU0ZipPiiy31J0umfmtEn4o5iLh0G0tXGxKdqM=; b=am75+R0B52VWZlm3mqs7trSXm+T+G53He4BcOvrEWHHyUABRQS7m4VaBZ0iz2GtcpE BmBOvuYxO/yqwfxFnWXXm1aInQCX0clgn3vM3ZJvM+5wvb/F8m6D3bNo6Jp2jTNYu5rf 3P2BZzBGhmBI5jpiLfJ0X1LMU9qCwNNRhnoDRbMfz4wptCLHFmeKzAfSd2SJHI7m7MvR lEQQNSR/WsCFD8y1eAuRdsDQ5as/6Js8wzgUECO48sj5rI8aXjL7JpzUPaPRFMwNAUd6 physnYqi0geRWQjvviuNw8Ysq4WBDO9w6nVh3SylDoWsK5kfZyc34tMwD69bSL43fNnJ 4RTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uyrIqaY7; spf=pass (google.com: domain of edumazet@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=edumazet@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i5sor16852900iti.30.2019.03.18.10.35.27 for (Google Transport Security); Mon, 18 Mar 2019 10:35:27 -0700 (PDT) Received-SPF: pass (google.com: domain of edumazet@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uyrIqaY7; spf=pass (google.com: domain of edumazet@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=edumazet@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PrCO2lU0ZipPiiy31J0umfmtEn4o5iLh0G0tXGxKdqM=; b=uyrIqaY7oC9B9nG/UxXrp2razNOLtRgLgzTki3DkPSo3hKZBihhOVs5XMPl0tSTbG9 8BkxMAekwOpEr5c18J94vX/PHkd/cR8S37JaGiHv2rHoQtCm8VN0JQT4bVDxL4DnFuaf TBpB7mtD1xZMSM6CEOwzN6ylMmjBtpj/81knOnGPRXtUhR49sy3r7rujNqeJpemmcNe/ yahcAmwycILMB5vkZoN8PLSOFNCEEoAnrHt4dlbEmOy7anc6ZJcANenVW5WZHg63bVhQ EDhXKW0Z+zXP/J6GAQ7GCYiiP+UrBe+V732dR9WdPtz9JuQLQBUDqkDSRPo5Tqt0+iTo c1OQ== X-Google-Smtp-Source: APXvYqw7xww6FQki8SuPZw8IxP5jWoWikBVhp58R4A7DMUEMPaLunFv8UC7JQGZkd4Yza/sj1u2HgqSyKYRRdWhydLY= X-Received: by 2002:a05:660c:842:: with SMTP id f2mr25940itl.142.1552930526937; Mon, 18 Mar 2019 10:35:26 -0700 (PDT) MIME-Version: 1.0 References: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> In-Reply-To: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> From: Eric Dumazet Date: Mon, 18 Mar 2019 10:35:14 -0700 Message-ID: Subject: Re: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive To: Andrey Konovalov Cc: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Linux ARM , "open list:DOCUMENTATION" , linux-mm , linux-arch , netdev , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , LKML , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Mar 18, 2019 at 10:18 AM Andrey Konovalov 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 > --- > 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; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6040C43381 for ; Mon, 18 Mar 2019 17:35:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98A4820854 for ; Mon, 18 Mar 2019 17:35:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="J39Pp3aA"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="uyrIqaY7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98A4820854 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yre6vUvHZ5YijbbbuebZxvojkm7poyl1HV/G2izoEuk=; b=J39Pp3aADJ1ryp eRuHgXqwynksH0vE3jlmu445UExLJPnAUHVAbx6b2LyHSeAVufYxASCTG/62THjoBqnG/R2r66Skt Z0HjC5Rq+FR5Bls9JMLct06Z4k5oRvjcMxNkfIBcIPoX0k5R0ojKJ1l7DRgh6tLHrwjLOARldXccV i6Z++iRlF1Bn1pD2bJxAV+ic0TxTeuJhBqww4eGJaeQ6lcByZ6PNzmbqsV+CEFCeGLizv/pRB8ZEB Rm2/VPtiHtNaILO17XIhaXfjw3l3M9euaerRdJPoIrrqPFb4WuwX4tk+Q+l58kOFBOHTYbbKgNO04 f7jO1SMaRCun0ZctyCLA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5wAe-0006lR-SR; Mon, 18 Mar 2019 17:35:32 +0000 Received: from mail-it1-x143.google.com ([2607:f8b0:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5wAa-0006kg-Kh for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 17:35:30 +0000 Received: by mail-it1-x143.google.com with SMTP id m18so5065098ita.3 for ; Mon, 18 Mar 2019 10:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PrCO2lU0ZipPiiy31J0umfmtEn4o5iLh0G0tXGxKdqM=; b=uyrIqaY7oC9B9nG/UxXrp2razNOLtRgLgzTki3DkPSo3hKZBihhOVs5XMPl0tSTbG9 8BkxMAekwOpEr5c18J94vX/PHkd/cR8S37JaGiHv2rHoQtCm8VN0JQT4bVDxL4DnFuaf TBpB7mtD1xZMSM6CEOwzN6ylMmjBtpj/81knOnGPRXtUhR49sy3r7rujNqeJpemmcNe/ yahcAmwycILMB5vkZoN8PLSOFNCEEoAnrHt4dlbEmOy7anc6ZJcANenVW5WZHg63bVhQ EDhXKW0Z+zXP/J6GAQ7GCYiiP+UrBe+V732dR9WdPtz9JuQLQBUDqkDSRPo5Tqt0+iTo c1OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PrCO2lU0ZipPiiy31J0umfmtEn4o5iLh0G0tXGxKdqM=; b=KpP6Cl1o1Ju5IAiz/1d9jSfYP3sqDebQbsYNmaOJAcGJMW2zeEwbqWUCzEYjz/fYSs 8n20SxRQhSG/HlzE3XA+NaeYVFMgPSDBc5zRlNsu3V2Smp5I/FoR1fpHoAJa1On5LgVu uVOifykxIHuQ2BxFAYeK2xQEXmo5+IotJBZVLU6jmJq5rgiIHnn7C+dZ9/1RBD9SmYJO 2wrnk2RtXNNr46ohOMuyjH5JjlCiObFWR4GnuWp3IuNTUMcTJPlvZofzYW+T4WHW9jgB F2yPWA8bONwmgN/wjkWbkFzuKIhFTEq0apaN5CoyL1aZIvQ2q3i/3NTERhkiJA0v7fjk UPyw== X-Gm-Message-State: APjAAAWq1B1C3FkPK3FYAEkQ0t5lk+1Ep4/SSl+ymFzkUL2xmK2O650t 2TEr7p4CLWdGtFEunPEs4u+NI5/wHZne/FyY8m0++w== X-Google-Smtp-Source: APXvYqw7xww6FQki8SuPZw8IxP5jWoWikBVhp58R4A7DMUEMPaLunFv8UC7JQGZkd4Yza/sj1u2HgqSyKYRRdWhydLY= X-Received: by 2002:a05:660c:842:: with SMTP id f2mr25940itl.142.1552930526937; Mon, 18 Mar 2019 10:35:26 -0700 (PDT) MIME-Version: 1.0 References: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> In-Reply-To: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> From: Eric Dumazet Date: Mon, 18 Mar 2019 10:35:14 -0700 Message-ID: Subject: Re: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive To: Andrey Konovalov X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_103528_682150_2E45AF09 X-CRM114-Status: GOOD ( 21.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Kate Stewart , "open list:DOCUMENTATION" , Peter Zijlstra , Catalin Marinas , Will Deacon , Alexei Starovoitov , linux-mm , "open list:KERNEL SELFTEST FRAMEWORK" , Chintan Pandya , Vincenzo Frascino , Shuah Khan , Ingo Molnar , linux-arch , Jacob Bramley , Daniel Borkmann , Szabolcs Nagy , Ingo Molnar , Dmitry Vyukov , Ramana Radhakrishnan , Dave Martin , Evgeniy Stepanov , Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Lee Smith , Steven Rostedt , Arnaldo Carvalho de Melo , bpf , Linux ARM , Kostya Serebryany , Greg Kroah-Hartman , LKML , Luc Van Oostenryck , netdev , Andrew Morton , Robin Murphy , "David S. Miller" , "Kirill A . Shutemov" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 18, 2019 at 10:18 AM Andrey Konovalov 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 > --- > 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; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel