From patchwork Fri Mar 9 14:02:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 883644 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="u2qusyF6"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="KlhatkzH"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zyTbf1BNKz9s7T for ; Sat, 10 Mar 2018 01:02:38 +1100 (AEDT) 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=q3wQlXCEPydTZAjaFgnArX0d2ob9XEAbSr4Iqh4Wiq8=; b=u2qusyF6jaeinH4lTdCIwGhYjr zl78gpJNo0dgtRxoCqeyLwP0ZsshOHP/swNOZnMAQSvpjbEXGe5J0i6e9KeUfLPsq3K86PUbEOOf3 LJRgcImSYVigqF92xwGbW8WnvqWijGW+Nx2oaGYN69XIJDRMpRopCOgJzT90g/fiQKVouPxH2Rp0C SIRRadbEwsSqx8a9h43Z/8RN4bon2DZwIsLSs2317FemnjsWnrJKTE4M9qjLhiCz6wLTOhXArWUp5 9UYlQ6RarhZZj2ds6KbAUM3W8glmFf9oNznGrZ89YPc3OxrHtjevmDrZsUXpVs5bSGOEOcYTCiN5Y w3ZkcsJw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euIbT-00037o-DU; Fri, 09 Mar 2018 14:02:35 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euIbJ-00030K-MS for linux-snps-arc@lists.infradead.org; Fri, 09 Mar 2018 14:02:32 +0000 Received: by mail-wm0-x242.google.com with SMTP id x7so4099800wmc.0 for ; Fri, 09 Mar 2018 06:02:23 -0800 (PST) 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=bFC+dOL1kofLW/Fz0q3F9Mambpm3ECJQAGpTBpsRBqY=; b=KlhatkzHSpgVRHDvB7Xo8ArpzJdEHpIrp8YwbhdYo36/+atn/MwbTUVLka2ecwucpk zBkNsc/ZMMJC76qRsNG3L0OoPeCXCuFE7Kwg/k6sQTOci9s0Te+5aqQGcaddiMIp8+48 cotuP8JIMQkN1iOw5U/gZASe/hLxJgyCR6kF8N6NJqAioxDCKZAMC5XrY+pSXPTrP1hG ymOU5dlpgdVaUvbvPpc5rS+PJ/C75VxYJYfyyyQFf8mKnfu4cQY9WZaCPo5Cs73J1Qcw jX3tqNstWDM+vhRI5hDVJ//BT12ne/5yFiHKvWzTjTCQMbeyPVZJVe1wN4cmr/5fq4d4 o+nQ== 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=bFC+dOL1kofLW/Fz0q3F9Mambpm3ECJQAGpTBpsRBqY=; b=GGVEmEUXTrse9DyV37ri6dxA4LzYiWpU/HJkfrorPN/fSLb1qMxA1NKOk/STiDHCL6 nOGAgNw8jDPZExKbbfrpR9l4HPsPjsRrsNAeGEUIXqLXCGwhYHlX/4NgikmRy4HLirE0 I8HoNyNdRHrQlXCGab5DPMPtccINKN6134jFahIs3HxSvHfNMTWxcE00Tily2mj/qEQZ pgffJHV7SEhGZVpp/x6qoGCDebsA5f4txF/iNcoKwJAc7k9wAzkavJgh8NdeOFBNVlOY QtbgJlraZGvkNCOkcEjL1RvXSO2UOTgB3HXgNTkCcsqdRMSEc7TlW8hMLBnpdni6sKas HppQ== X-Gm-Message-State: AElRT7HmrxWN051zlfZ11doSrC0FPw+PpH/C+ctaytwzfLdgBnEJo9aP xUcXcoTCUvmU/nLbwxGURJ+cfg== X-Google-Smtp-Source: AG47ELur63iUzTcj/SxULK7/n9/IiOYomFoFueFSfoU9XvqGgqC5/NqRiMXXZBMSOAU5srV8yEvX2w== X-Received: by 10.28.230.68 with SMTP id d65mr2300974wmh.13.1520604141250; Fri, 09 Mar 2018 06:02:21 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id f3sm994484wre.72.2018.03.09.06.02.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 06:02:20 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Philippe Ombredanne , Greg Kroah-Hartman , Thomas Gleixner , Kate Stewart , Andrew Morton , "Kirill A . Shutemov" , Ingo Molnar , "Aneesh Kumar K . V" , Minchan Kim , Michal Hocko , Shaohua Li , Andrea Arcangeli , Anshuman Khandual , Mike Rapoport , Vlastimil Babka , Naoya Horiguchi , Shakeel Butt , Joonsoo Kim , Hugh Dickins , Mel Gorman , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Mike Kravetz , Zi Yan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , Mark Salter , Aurelien Jacquiot , Mikael Starvik , Jesper Nilsson , Tony Luck , Fenghua Yu , Geert Uytterhoeven , James Hogan , Michal Simek , Ralf Baechle , David Howells , Ley Foon Tan , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E . J . Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Palmer Dabbelt , Albert Ou , Chen Liqin , Lennox Wu , Yoshinori Sato , Rich Felker , "David S . Miller" , Ingo Molnar , x86@kernel.org, Chris Zankel , Max Filippov , Arnd Bergmann , linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, adi-buildroot-devel@lists.sourceforge.net, linux-c6x-dev@linux-c6x.org, linux-cris-kernel@axis.com, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, linux-am33-list@redhat.com, nios2-dev@lists.rocketboards.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org Subject: [RFC PATCH 4/6] mm, arm64: untag user addresses in mm/gup.c Date: Fri, 9 Mar 2018 15:02:02 +0100 Message-Id: X-Mailer: git-send-email 2.16.2.395.g2e18187dfd-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-20180309_060225_812756_C3400D34 X-CRM114-Status: GOOD ( 15.28 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Evgeniy Stepanov MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 1b46e6e74881..4d820c4792d7 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); @@ -1746,6 +1754,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; @@ -1798,6 +1808,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;