From patchwork Mon Mar 18 17:17:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10858221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D9DB6C2 for ; Mon, 18 Mar 2019 17:19:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E259722F3E for ; Mon, 18 Mar 2019 17:19:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1F8D28066; Mon, 18 Mar 2019 17:19:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A05622F3E for ; Mon, 18 Mar 2019 17:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727470AbfCRRTG (ORCPT ); Mon, 18 Mar 2019 13:19:06 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:47451 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727957AbfCRRSO (ORCPT ); Mon, 18 Mar 2019 13:18:14 -0400 Received: by mail-qt1-f201.google.com with SMTP id z34so11972505qtz.14 for ; Mon, 18 Mar 2019 10:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=nIZeb0pZ+Rs1twP/26IxdjvHz5r8ncIzXCkOe4U4COg=; b=EXAkqzYXquwoZW9zPquYoEc1VixgrJrxtJjurULtOsll9F/x8BSgkuYbNYqPNAK+sc QdGu01FYNxKrm1YnjhDssa3BGmNkam/8XvRG+67blmdUDkqpgD3yiL0tqlkzvcOHlEdD fz/vfMUJKMxApfo9M6ta6ANBN/hBFJ8sHT6IIlVMu94hJTj8vY7Ch6oVS78GY6mduhfg Mfa3G2yUPRZbMrYKuIq4vjmPLT9/Hrg9S0x5wCC0nEBvOOrzKzgwcqVZmA0wCyKJejEO fM02iW8f+3jGAOZtPgjTq3dSiMBluDfCCoyJ/neHAzTlpna8RAP9peqgVYpDqOfBkGtD dYvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=nIZeb0pZ+Rs1twP/26IxdjvHz5r8ncIzXCkOe4U4COg=; b=fn2xFnlIjFB6SQKTKoWUWxUkuQYyYJuZJcU3m8wXXEPgzm0p07EKGl+66AsSTzKGBw ib9aai5vxWZ+ikVrb2xmwvat9j/VZJcSofzd64tiYFV3MsK8uqhvb5R1tGZYx8tXgFr5 gGj4PDSnaCWCXiGvuMzRlXzHHD631sz35CH1RDvqPguYXZit0rBaVx43wtpN+c6Zp+Tv 8Kg15YRrMnjg0Ty4VYWWp5MFEkV3YrFcPPW2/Xv9HcS1zZ+DLKPmiYfLG/Nrxye3z98M jz3DRX7TvkdWqGTtq9UflEVUyhJakPQraY25EKFf1+LEcv7xsW6XWsS5ejUTz6Ak707V MiNQ== X-Gm-Message-State: APjAAAUAusz31YZVbe+l+les9GkCNbiL+YKlNVAwb3SkbQ6l3nYQWUPU xMm+7ps43OY6ky+kBnps0p29Ljumxa8otNbF X-Google-Smtp-Source: APXvYqxadZqo6uzYQyuENLgyHusNMUz8mCv/BxMvfZyt1rftgNKCVV69MZQdKa9n4B6FLFRP2mw6D3xauqnW81d3 X-Received: by 2002:ac8:38b7:: with SMTP id f52mr10498903qtc.7.1552929493810; Mon, 18 Mar 2019 10:18:13 -0700 (PDT) Date: Mon, 18 Mar 2019 18:17:40 +0100 In-Reply-To: Message-Id: <80e79c47dc7c5ee3572034a1d69bb724fbed2ecb.1552929301.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v12 08/13] net, arm64: untag user pointers in tcp_zerocopy_receive From: Andrey Konovalov To: 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 , Eric Dumazet , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: 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 , Andrey Konovalov Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)