path: root/mm/process_vm_access.c
diff options
authorDave Hansen <>2016-02-12 13:01:54 -0800
committerIngo Molnar <>2016-02-16 10:04:09 +0100
commit1e9877902dc7e11d2be038371c6fbf2dfcd469d7 (patch)
tree715a45eca4c79168f0351421a7584c95212331f8 /mm/process_vm_access.c
parent1fe3f29e4a908461be16a9388e73837157cc7942 (diff)
mm/gup: Introduce get_user_pages_remote()
For protection keys, we need to understand whether protections should be enforced in software or not. In general, we enforce protections when working on our own task, but not when on others. We call these "current" and "remote" operations. This patch introduces a new get_user_pages() variant: get_user_pages_remote() Which is a replacement for when get_user_pages() is called on non-current tsk/mm. We also introduce a new gup flag: FOLL_REMOTE which can be used for the "__" gup variants to get this new behavior. The uprobes is_trap_at_addr() location holds mmap_sem and calls get_user_pages(current->mm) on an instruction address. This makes it a pretty unique gup caller. Being an instruction access and also really originating from the kernel (vs. the app), I opted to consider this a 'remote' access where protection keys will not be enforced. Without protection keys, this patch should not change any behavior. Signed-off-by: Dave Hansen <> Reviewed-by: Thomas Gleixner <> Cc: Andrea Arcangeli <> Cc: Andrew Morton <> Cc: Andy Lutomirski <> Cc: Borislav Petkov <> Cc: Brian Gerst <> Cc: Dave Hansen <> Cc: Denys Vlasenko <> Cc: H. Peter Anvin <> Cc: Kirill A. Shutemov <> Cc: Linus Torvalds <> Cc: Naoya Horiguchi <> Cc: Peter Zijlstra <> Cc: Rik van Riel <> Cc: Srikar Dronamraju <> Cc: Vlastimil Babka <> Cc: Cc: Link: Signed-off-by: Ingo Molnar <>
Diffstat (limited to 'mm/process_vm_access.c')
1 files changed, 8 insertions, 3 deletions
diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
index 5d453e58ddbf..07514d41ebcc 100644
--- a/mm/process_vm_access.c
+++ b/mm/process_vm_access.c
@@ -98,9 +98,14 @@ static int process_vm_rw_single_vec(unsigned long addr,
int pages = min(nr_pages, max_pages_per_loop);
size_t bytes;
- /* Get the pages we're interested in */
- pages = get_user_pages_unlocked(task, mm, pa, pages,
- vm_write, 0, process_pages);
+ /*
+ * Get the pages we're interested in. We must
+ * add FOLL_REMOTE because task/mm might not
+ * current/current->mm
+ */
+ pages = __get_user_pages_unlocked(task, mm, pa, pages,
+ vm_write, 0, process_pages,
if (pages <= 0)
return -EFAULT;