From patchwork Wed Apr 18 18:53:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10348797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A1AB4601D7 for ; Wed, 18 Apr 2018 18:53:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E33B2866C for ; Wed, 18 Apr 2018 18:53:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 829F9287F2; Wed, 18 Apr 2018 18:53:52 +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=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D8AE92866C for ; Wed, 18 Apr 2018 18:53:51 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ngi6uUOjA0qDgk3SKi4XjuqMymcKLOuG2fBzJUTDaTc=; b=eOp0w0eyBnPRzRqFAKX1dZB773 8TgxABOwkHklFmvx+PhTwAdEitn7COtlC9QFC82fUiZmaPb2Om0+oP+QHKbABrEEi3Qvo2WyNxx3y 6N2hlY22t8gN2weGhPeME6oM1RF/qozrVnGAPzvd/d1RVxx+7jRYWoD9WBzNTgbbJKl1XkeJTJ7Im HvVwRGm2WM7sMkQPyjb0i9iz1kwcUy+Os0a4Y8sVO0PMN6XExADVJ0V50PLp18HJatMdLUbQxEdsn y7mimvD0h2WjdDnruhdmWuVVipw9el8iBxbKbyUjbGY8Qd5he00FxW/r13wfRjF7Aopvy3QY0KhLr LlYawNzw==; 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 1f8sD5-0002z6-Ac; Wed, 18 Apr 2018 18:53:39 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8sCy-0002v4-6u for linux-arm-kernel@lists.infradead.org; Wed, 18 Apr 2018 18:53:34 +0000 Received: by mail-wr0-x241.google.com with SMTP id s18-v6so7525491wrg.9 for ; Wed, 18 Apr 2018 11:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=PJ5XUe+ltNClCgiZ/w1sU8NdaWdPhX/PsNl2IWrnZo4=; b=a2pnlJdQ8EE/Aq3W32UwUHOB3LCELEG+hK21clc+673A0T4L6W1Toc0lzT0ElX/Rzj 8HR7P06fbA1L4DccXePrgQlCkE00y+a5rD/EbW1KMEcoXlZtOcdgKzZfxWx6i2GTPfWY 3DhDR3sieLdyhbt4rzMd/1n0Pf66nSZO+96FXs6ABP1wF59RSRHS4UNMiAgJi0M+UGas RAi+LsYXnlc3i2QijC53CWhKx1cUglDOHmGHE7lTE/wxfXoCbljhQF8BMZb5Eux8EDFW IYyv/hBzqIY7U1z1/9m4DjfEXzsnFunNTtdXbsDkGO7iLsP4NaJRXzn5/xmbuzhdLfvw jkug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=PJ5XUe+ltNClCgiZ/w1sU8NdaWdPhX/PsNl2IWrnZo4=; b=h/K796wtBQbSIVQgwGAyyd2rH4lOZkZDqBnXBw8HqbhMOs73OcZlDpzbrJyuoU5x1U U4c5ZTp/eqpbpxbN5UdLJRhEvpE1AaAHBMqiNcVV10VH8Oo9s4W/fFBdKAT4mj1mRW+M Zt8pOe9jGZMzn7S9nbm/BZm+7bkYAxmG8rp8SJ5xZvmRwwROys6kE/4SDX9a7pGbU2B6 qx8UDf9VTEsQEm+zhoNy9JePWHUJWcCxMPNPl9eEgMA2qvSuROtEhohezPhV7Rf1o13L ODDtswzXZgMtRCl5JxfDk3AQoYE7OuKvgppkaRTFV1PQn/Nb59ygNH3mdoNJzLuSgAb3 iifg== X-Gm-Message-State: ALQs6tD5iVP1tnlN+886VoPerZ7lRR5QL4/A5PUYV6V2+eLMNOuSIBBn jRUCtRmC0czCBSL7waW9lN8hbQ== X-Google-Smtp-Source: AIpwx49hGnmZ7BV/wHOQtwkJhcg6g5r3CZUaOrWwmlL9x26D+GKFTSsf9qRNCVnR7RVbNhjTM0wWOA== X-Received: by 10.28.5.198 with SMTP id 189mr2402518wmf.155.1524077604918; Wed, 18 Apr 2018 11:53:24 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k79sm2616735wmg.39.2018.04.18.11.53.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 11:53:24 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Jonathan Corbet , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , James Morse , Kees Cook , Bart Van Assche , Kate Stewart , Greg Kroah-Hartman , Thomas Gleixner , Philippe Ombredanne , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Dan Williams , "Aneesh Kumar K . V" , Zi Yan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/6] mm, arm64: untag user addresses in mm/gup.c Date: Wed, 18 Apr 2018 20:53:13 +0200 Message-Id: <0db34d04fa16be162336106e3b4a94f3dacc0af4.1524077494.git.andreyknvl@google.com> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-goog In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180418_115332_868957_A73C1E48 X-CRM114-Status: GOOD ( 15.00 ) 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: Jacob Bramley , Ruben Ayrapetyan , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Evgeniy Stepanov MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP mm/gup.c provides a kernel interface that accepts user addresses and manipulates user pages directly (for example get_user_pages, that is used by the futex syscall). Here we also need to handle the case of tagged user pointers. Untag addresses passed to this interface. Signed-off-by: Andrey Konovalov --- mm/gup.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index 76af4cfeaf68..fb375de7d40d 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -386,6 +386,8 @@ struct page *follow_page_mask(struct vm_area_struct *vma, struct page *page; struct mm_struct *mm = vma->vm_mm; + address = untagged_addr(address); + *page_mask = 0; /* make this handle hugepd */ @@ -647,6 +649,8 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, if (!nr_pages) return 0; + start = untagged_addr(start); + VM_BUG_ON(!!pages != !!(gup_flags & FOLL_GET)); /* @@ -801,6 +805,8 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, struct vm_area_struct *vma; int ret, major = 0; + address = untagged_addr(address); + if (unlocked) fault_flags |= FAULT_FLAG_ALLOW_RETRY; @@ -854,6 +860,8 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk, long ret, pages_done; bool lock_dropped; + start = untagged_addr(start); + if (locked) { /* if VM_FAULT_RETRY can be returned, vmas become invalid */ BUG_ON(vmas); @@ -1751,6 +1759,8 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, unsigned long flags; int nr = 0; + start = untagged_addr(start); + start &= PAGE_MASK; addr = start; len = (unsigned long) nr_pages << PAGE_SHIFT; @@ -1803,6 +1813,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write, unsigned long addr, len, end; int nr = 0, ret = 0; + start = untagged_addr(start); + start &= PAGE_MASK; addr = start; len = (unsigned long) nr_pages << PAGE_SHIFT;