From patchwork Tue Mar 27 16:57:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10311131 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 2A9C36037D for ; Tue, 27 Mar 2018 17:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 197CE29D69 for ; Tue, 27 Mar 2018 17:01:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DE1529D82; Tue, 27 Mar 2018 17:01:04 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID 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 A3FBC29D6E for ; Tue, 27 Mar 2018 17:01:03 +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=SfWVe3sXKCJSvjHLpMU664nS+hxmFzokPCNm92W1uS8=; b=BN+pyVv3T24pzb9kS8W7lqcebh W8Rc1UuWunxbndT+60HPpZCB8YlTG9YZMQk7Fshwhwa9bkbwqKibqvNTJLECPVgII9/OX+gbGH9ZP 5DPyTkQ/p81/6qeJY2TSw+ZZ4aWh3Bpw9Am2u8FReSLc9t9ddh6gqkwWm9EhG6ekLLmkAmUUIa+ba 5UWNoXic5q0vNl9cvUC/mXx3d40hTg1T1Mi4Fm/2/8aUezXzzpj2ni1G1m7RSO8uUE+T8vjMyPzhf 5hXNwBzAawyx5F7yEutQz9qR4yvHIhSObDSjNe6ni30T7cu2aZuNL+InUfjUL+DMhutpJI0tXHdC8 V/mKJV5w==; 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 1f0rxy-00035L-RI; Tue, 27 Mar 2018 17:00:58 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0rvA-000808-Vy for linux-arm-kernel@lists.infradead.org; Tue, 27 Mar 2018 16:58:06 +0000 Received: by mail-wr0-x244.google.com with SMTP id u46so23109709wrc.11 for ; Tue, 27 Mar 2018 09:57:54 -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=cacUgNErAiacdTm28Hw85KMBEjc9e53EfkZQ5WfCyjc=; b=TEg6GMmYudebHk3naSLGDxAz24RtZKAI7Fp8n1XbFtDA59s1tCq35rlCkOqpyVLnEz BhbdfkUfoTIuQcHKlL10bLZjwp6M+fznJggYzkramExnbXEHjk2GNppjshI9aSdya10A k8n7Xh1XWYTwptf5qBzmGffx3NCA2UkrId2FB2u4bdZ6C12FVMks+wcbZixgxNTiOQgJ +YbZQV4H/069YcPIo9b63r5QIa0sppp60hc+RS7Qm9gnBIFYTVL3l+Usj2mJKtQrBFfK CAMXrT4Yv0yNlAZC5KitYYxC8e0VP8W0sXd+5IdtYyVUZTe43f+1Rr+bxsPBmXhC1tNz q8IQ== 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=cacUgNErAiacdTm28Hw85KMBEjc9e53EfkZQ5WfCyjc=; b=W9hxPK1Cpqbdsm5OD6u945/7yHW6GcLJ9XOV/N7LFiJMhLp6UveabRDouKWMY5bvAm k1BIaaKvYWn1V45q2lcg7Gt2hWkqckXR3wQoRoTlUrd/8n7CIGrZqnzW+onD8dOPlb4T Fyna2O8saoD/6pESmki+Hwp7nLUz/wqE3+qAVWIRQ/VMmJo36n6WTugb5SkYh91lYYym pqLVEq6eYubPxLBjCHKDFSSLQv62DWYR5fmZ2AjjdrrwftGBwQFuX5MqUJo0KmY770Ex +tc5X7r3CRsHaGkmyci+rhKEtYbVmm7HJPJmN86J5VtReRZJU5mK3jlLxmMWK8E3nUBN 5Cpg== X-Gm-Message-State: AElRT7GtrPU6eS9Dp0PMQpu2rvNzv6U/2u2KIEuS+R1RFZg3bDVIJ+TN s42meieIovfkbyWbTo70nJKF9g== X-Google-Smtp-Source: AIpwx48/QtGfl4IRtqr4mAXPt9oSOb47MZa+Ey39W0BnqqXfqnZ7EpSWaMB+jlXhxDcmsxCAtafe2w== X-Received: by 10.223.199.132 with SMTP id l4mr147276wrg.6.1522169873001; Tue, 27 Mar 2018 09:57:53 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 93sm1622992wrh.46.2018.03.27.09.57.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 09:57:52 -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: [RFC PATCH v2 4/6] mm, arm64: untag user addresses in mm/gup.c Date: Tue, 27 Mar 2018 18:57:40 +0200 Message-Id: X-Mailer: git-send-email 2.17.0.rc0.231.g781580f067-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-20180327_095805_047974_3A5ACC83 X-CRM114-Status: GOOD ( 15.28 ) 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 6afae32571ca..9c4afcf50dfa 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); @@ -1749,6 +1757,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; @@ -1801,6 +1811,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;