From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: ARC-Seal: i=1; a=rsa-sha256; t=1522169873; cv=none; d=google.com; s=arc-20160816; b=vkQuOt4rF/trkbXlW0T1UtLa/6OaQAo4f5kgiQoSWmrg80ygEg3Sv2qTwGn4PSWe0M 4RfwtV59w9qQ7pY925BStVix81HUVSDpqWSKFknkKidlvDkY+2+iqIyfAyOs3BFwQ0F1 CvLHPHp5MjxopANfYp8KUPzevuT8U60q0xYgf8L9l8Bzx2fJAGx9HhaHcX4Kh8o27TH0 7hgxK3mn7XYxydv6DksH8uoia9fR1AXMAVPoSxm2zgQH6qr6ybWuyKiuL7Et+VycvPdx qeodNrtSw6YVce2ZMQthLPp3NDDlQw65QJy1i7ckS0cLGiDR3hvvEhp+kauKOPOQqiwc IWXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=cacUgNErAiacdTm28Hw85KMBEjc9e53EfkZQ5WfCyjc=; b=zxOUobFXFrDWqX5VCecnvcqhrSX7HNYUoVcPcTZDYSNF+eADgZmTBPIxs6PketUEAA YMjx80oihv6Jl5t5P3xMAV4V3WxdNBs4jdlGNxSh1Q1t+NtEs1WkRIBTACYJyyyKayEV qbOT8MsWhYpPLEYJxLZ0N4ZaBzQqWfauifGPsCzFs1W8hql3AvwIioEf74lRYoThXVbq tIYXJ0OwRmFHLCNVRrfqNj2ipf1vosbPcS3ZJ1a+vD+hUgbVefRgdCxFCMaMpoM8SH9s 2W9pJBh58isdXpRx0QNCo6RRC0oOCcz5BF1KjamT+8gvf5a4Yurf7KIezuKTRacHAMMf 6lXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TEg6GMmY; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TEg6GMmY; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Google-Smtp-Source: AIpwx48/QtGfl4IRtqr4mAXPt9oSOb47MZa+Ey39W0BnqqXfqnZ7EpSWaMB+jlXhxDcmsxCAtafe2w== 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 Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1596110797384518600?= X-GMAIL-MSGID: =?utf-8?q?1596110797384518600?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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; -- 2.17.0.rc0.231.g781580f067-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-4.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,T_DKIM_INVALID, T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id 495A97DE76 for ; Tue, 27 Mar 2018 16:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751122AbeC0Q7O (ORCPT ); Tue, 27 Mar 2018 12:59:14 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:43420 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755428AbeC0Q5y (ORCPT ); Tue, 27 Mar 2018 12:57:54 -0400 Received: by mail-wr0-f193.google.com with SMTP id p53so15591784wrc.10 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=fUUbf3pFc2koLii/av9JowLTie8DtoYmJt+WBdY0kkWzJLiCqV1VYNnr3zBj1pYbKl mhahpcuDI/miKR75+V8qqbjWjPAU/uIx7aYYZxhMBqBkqVVN7VKy0wmvYCsQ4VJDiYYk IZ/ErKtMMRZ5hqRLMWnVeYthl/1yb5dSmUVKi1GJGZIMRFTu/wodR0tg3PW9CE/B/yZ/ mTOO0DGd3anzM+59fSh3eBRdgL+MKa8jhzrheAqT5rFQzv50Wstdez79twdsnf6Tsoeb MdMRhrvF72eziWBEA7dCu5m0cW0vvWMXBeyuFGg+jfS3pjKtsqMQrK1FCcT5p123oeAB ctwQ== X-Gm-Message-State: AElRT7Hhp3vI3sgGq5C4ti2RfCGZe0BvcuK2qBkOWT8OWZy3oQET81fW SioiiWrkfcEpGMXTL8QIDh83EA== 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 Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan 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: Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.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 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; -- 2.17.0.rc0.231.g781580f067-goog -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: andreyknvl@google.com (Andrey Konovalov) Date: Tue, 27 Mar 2018 18:57:40 +0200 Subject: [RFC PATCH v2 4/6] mm, arm64: untag user addresses in mm/gup.c In-Reply-To: References: Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.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 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; -- 2.17.0.rc0.231.g781580f067-goog