[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-d4925e00d59698a201231cf99dce47d8b922bb34@git.kernel.org>
Date: Thu, 18 Feb 2016 12:21:30 -0800
From: tip-bot for Dave Hansen <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: aneesh.kumar@...ux.vnet.ibm.com, dvlasenk@...hat.com,
jason.low2@...com, bp@...en8.de, torvalds@...ux-foundation.org,
dan.j.williams@...el.com, riel@...hat.com, dave@...1.net,
kirill.shutemov@...ux.intel.com, akpm@...ux-foundation.org,
hpa@...or.com, linux-kernel@...r.kernel.org, brgerst@...il.com,
luto@...capital.net, dave.hansen@...ux.intel.com,
sasha.levin@...cle.com, dingel@...ux.vnet.ibm.com,
peterz@...radead.org, tglx@...utronix.de, mingo@...nel.org,
emunson@...mai.com
Subject: [tip:mm/pkeys] mm/gup: Factor out VMA fault permission checking
Commit-ID: d4925e00d59698a201231cf99dce47d8b922bb34
Gitweb: http://git.kernel.org/tip/d4925e00d59698a201231cf99dce47d8b922bb34
Author: Dave Hansen <dave.hansen@...ux.intel.com>
AuthorDate: Fri, 12 Feb 2016 13:02:16 -0800
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Thu, 18 Feb 2016 09:32:43 +0100
mm/gup: Factor out VMA fault permission checking
This code matches a fault condition up with the VMA and ensures
that the VMA allows the fault to be handled instead of just
erroring out.
We will be extending this in a moment to comprehend protection
keys.
Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
Reviewed-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andy Lutomirski <luto@...capital.net>
Cc: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Brian Gerst <brgerst@...il.com>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Dave Hansen <dave@...1.net>
Cc: Denys Vlasenko <dvlasenk@...hat.com>
Cc: Dominik Dingel <dingel@...ux.vnet.ibm.com>
Cc: Eric B Munson <emunson@...mai.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Jason Low <jason.low2@...com>
Cc: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Rik van Riel <riel@...hat.com>
Cc: Sasha Levin <sasha.levin@...cle.com>
Cc: linux-kernel@...r.kernel.org
Cc: linux-mm@...ck.org
Link: http://lkml.kernel.org/r/20160212210216.C3824032@viggo.jf.intel.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
mm/gup.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index de24ef4..b935c2c 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -610,6 +610,18 @@ next_page:
}
EXPORT_SYMBOL(__get_user_pages);
+bool vma_permits_fault(struct vm_area_struct *vma, unsigned int fault_flags)
+{
+ vm_flags_t vm_flags;
+
+ vm_flags = (fault_flags & FAULT_FLAG_WRITE) ? VM_WRITE : VM_READ;
+
+ if (!(vm_flags & vma->vm_flags))
+ return false;
+
+ return true;
+}
+
/*
* fixup_user_fault() - manually resolve a user page fault
* @tsk: the task_struct to use for page fault accounting, or
@@ -645,7 +657,6 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
bool *unlocked)
{
struct vm_area_struct *vma;
- vm_flags_t vm_flags;
int ret, major = 0;
if (unlocked)
@@ -656,8 +667,7 @@ retry:
if (!vma || address < vma->vm_start)
return -EFAULT;
- vm_flags = (fault_flags & FAULT_FLAG_WRITE) ? VM_WRITE : VM_READ;
- if (!(vm_flags & vma->vm_flags))
+ if (!vma_permits_fault(vma, fault_flags))
return -EFAULT;
ret = handle_mm_fault(mm, vma, address, fault_flags);
Powered by blists - more mailing lists