Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1517095img; Tue, 19 Mar 2019 09:15:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlkkuY2nFkOiKDIBLKx+cSVDxWIemEDM2YcxzS3/n4YK5zsKG/SqYIO1N1d+k9pC79Qvua X-Received: by 2002:a65:614a:: with SMTP id o10mr2567667pgv.51.1553012155330; Tue, 19 Mar 2019 09:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553012155; cv=none; d=google.com; s=arc-20160816; b=RWRZUQRezDSwXXQPz4acagNhak38ELmRQEmm2+AugpawejVkmCnpKOQBwy93phxtKO 5ASDhI8Yxxze054HpWgJ42ctZS+wKeCXMTf7n6PUqH3lUqlx/t77McR5/OVsI7Z/8Fnm iMMaAZsaT8W6ZZkFlWQqsqmgTfeAe4LNca9yBMgtnmtXJ8Wb5DMXDME0PO1C1nDvSRSQ CpEHO70oblgR3xXDeCKfBkUUAEZBJGyEbHmScF0lmLqXX8V9oWl6oOf2LfDbiGcEux9d 9ZPSVVCttvC3VqMOW4GiVs4jTO+cegR2XeO2N1blyr3PYrzDUjOotg+316Vx9pdjzfz7 LZ4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PQgiC0kZ9u3Fy9QCp4MSDtSraYleFQhb/2xaBu2ZSrg=; b=MlkX5u3HaHrTl3KCNEOI+gLs9/bT37MjbZL4diNPRPzjN6/sONiG2gvbkHAf6zeQxU W0MvgUuH7BzGbHli8Q5uOzCZ0IyHuVS7kFCWK1eBFZUwR1jyE4r7eUPMpUYI7O7mryW+ sNr2zbyu4Ar+iO2ZlJGuYe1vYxKlgYH7kX0hKUYZOSTwgLQjOxecTfAS1w/YhRn94ckL IhbupeBEuaZy2kgSw1QlDUmIHEHbpKCAngkuea9XSCE44dSL+XLHDkf4oEpaL0Q/FwZe CeYnqaHjSClY3KKtUKbBSyxXZtGuvdNrhPEsIyqgTlR2uNlSYZzXKlxp30DyQ2SMatuJ tkkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qxq7DiID; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si2219651pgv.3.2019.03.19.09.15.39; Tue, 19 Mar 2019 09:15:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qxq7DiID; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727579AbfCSQPA (ORCPT + 99 others); Tue, 19 Mar 2019 12:15:00 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:43311 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbfCSQO7 (ORCPT ); Tue, 19 Mar 2019 12:14:59 -0400 Received: by mail-pf1-f195.google.com with SMTP id c8so7389628pfd.10 for ; Tue, 19 Mar 2019 09:14:59 -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=PQgiC0kZ9u3Fy9QCp4MSDtSraYleFQhb/2xaBu2ZSrg=; b=qxq7DiIDvuLMVQ34GJzbbwphhe3KaybKNLLIgWZcGxMMwPerSCP8RL7QKUW6OtyBKf 93s0/L1vzqFcVzh/gw7Cxoq5tPb1/WaJXpXJp3yNxXHHX+7WMTlqOagmGKRDtUxEMSKg 5DS0enSD5PzEjo4jy+UcwIsjiJOFl6BnvOboDUvPFYRjHX6Bkquppw7J1+eqRrui0XyJ 5KwS2/Yj9IcZSKFd33h7Wg5DbPnCVWpSh5pGJ75s8D7bMH8YcmfdqR842AAg13swxCOv Kk2MxlHMbY3GoTWt8xmPsHQ5oVfatT1NEXrOp0w5gHtoFSTLFLhBqpyqHShIAnZJ8YpW APtQ== 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=PQgiC0kZ9u3Fy9QCp4MSDtSraYleFQhb/2xaBu2ZSrg=; b=TirQHLZap167mZWI0b+mQRpvmbEBF1OVz09+6yKTztvMMuGbBMEszKXQgS378JLoQj stt7T6nCirBDXnRSq25tBTB1EjWP118SkwxkK6eu91RXd/ItX75omaE0tXTgMKJ+hiqt tcig86GIlFqbBz/aeWinJ0MDoCYMqTeXT8m1Jc9sWqB0TB5OahFoW9eWxWhjgpvtUbMH gEc5+CMBMobJ0g69E8dSWjOj+hqbNR3C4nZfS1wK4DBuAJ5cf3/WTcfJqZ2dd+mLGrG1 cfoddJTyMneXtnblmErBlR4lNFmmh4m9vLvBW12IFwMsfKlgPXXCCzv2k8T2mzX8/X+w Cnzw== X-Gm-Message-State: APjAAAVkH7F/T1OupxGLxocVsraAUbng+MfKhJPceJsLkkoAnF9JY4QJ 2FLap7ZPJfcose+ZT69hYVOZGNVFh+5yohqGV2u0Sg== X-Received: by 2002:aa7:8b12:: with SMTP id f18mr3253945pfd.240.1553012098901; Tue, 19 Mar 2019 09:14:58 -0700 (PDT) MIME-Version: 1.0 References: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> In-Reply-To: From: Andrey Konovalov Date: Tue, 19 Mar 2019 17:14:47 +0100 Message-ID: Subject: Re: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive To: Eric Dumazet 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 6:35 PM Eric Dumazet wrote: > > 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; Looks good, will do it like this in the next version. Thanks!