mm/core: Do not enforce PKEY permissions on remote mm access
[deliverable/linux.git] / mm / ksm.c
index c2013f638d113d073d0ca2814420619472c63915..b99e828172f6ef30e279e4d07b7a74ba9cbb36db 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -359,6 +359,10 @@ static inline bool ksm_test_exit(struct mm_struct *mm)
  * in case the application has unmapped and remapped mm,addr meanwhile.
  * Could a ksm page appear anywhere else?  Actually yes, in a VM_PFNMAP
  * mmap of /dev/mem or /dev/kmem, where we would not want to touch it.
+ *
+ * FAULT_FLAG/FOLL_REMOTE are because we do this outside the context
+ * of the process that owns 'vma'.  We also do not want to enforce
+ * protection keys here anyway.
  */
 static int break_ksm(struct vm_area_struct *vma, unsigned long addr)
 {
@@ -367,12 +371,14 @@ static int break_ksm(struct vm_area_struct *vma, unsigned long addr)
 
        do {
                cond_resched();
-               page = follow_page(vma, addr, FOLL_GET | FOLL_MIGRATION);
+               page = follow_page(vma, addr,
+                               FOLL_GET | FOLL_MIGRATION | FOLL_REMOTE);
                if (IS_ERR_OR_NULL(page))
                        break;
                if (PageKsm(page))
                        ret = handle_mm_fault(vma->vm_mm, vma, addr,
-                                                       FAULT_FLAG_WRITE);
+                                                       FAULT_FLAG_WRITE |
+                                                       FAULT_FLAG_REMOTE);
                else
                        ret = VM_FAULT_WRITE;
                put_page(page);
This page took 0.026347 seconds and 5 git commands to generate.