This patch enables propcesses that did not create the mshare region to map the region using mmap(). Signed-off-by: Khalid Aziz <khalid.aziz@xxxxxxxxxx> --- mm/mshare.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mm/mshare.c b/mm/mshare.c index 2ec0e56ffd69..455b10ca0cdf 100644 --- a/mm/mshare.c +++ b/mm/mshare.c @@ -144,7 +144,21 @@ msharefs_mmap(struct file *file, struct vm_area_struct *vma) * page table sharing */ if (new_mm->mmap_base != 0) { - return -EINVAL; + /* + * Any mappings of mshare region must use exact same + * virtual addresses + */ + if ((vma->vm_start != new_mm->mmap_base) || + (new_mm->task_size != (vma->vm_end - vma->vm_start))) + return -EINVAL; + + vma->vm_private_data = info; + /* + * mshare pages are shared pages that also share page table + */ + vma->vm_flags |= (VM_SHARED_PT|VM_SHARED); + vma->vm_ops = &msharefs_vm_ops; + refcount_inc(&info->refcnt); } else { struct mm_struct *old_mm; struct vm_area_struct *new_vma; -- 2.32.0