Merge branch 'upstream-master' into android-mainline
Partial 5.8-rc7 merge to make the final merge easier. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I95f1b0a379e3810333300a70c5a93f449d945c54
This commit is contained in:
16
mm/mmap.c
16
mm/mmap.c
@@ -2629,7 +2629,7 @@ static void unmap_region(struct mm_struct *mm,
|
||||
* Create a list of vma's touched by the unmap, removing them from the mm's
|
||||
* vma list as we go..
|
||||
*/
|
||||
static void
|
||||
static bool
|
||||
detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
|
||||
struct vm_area_struct *prev, unsigned long end)
|
||||
{
|
||||
@@ -2654,6 +2654,17 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
|
||||
|
||||
/* Kill the cache */
|
||||
vmacache_invalidate(mm);
|
||||
|
||||
/*
|
||||
* Do not downgrade mmap_lock if we are next to VM_GROWSDOWN or
|
||||
* VM_GROWSUP VMA. Such VMAs can change their size under
|
||||
* down_read(mmap_lock) and collide with the VMA we are about to unmap.
|
||||
*/
|
||||
if (vma && (vma->vm_flags & VM_GROWSDOWN))
|
||||
return false;
|
||||
if (prev && (prev->vm_flags & VM_GROWSUP))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2834,7 +2845,8 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
|
||||
}
|
||||
|
||||
/* Detach vmas from rbtree */
|
||||
detach_vmas_to_be_unmapped(mm, vma, prev, end);
|
||||
if (!detach_vmas_to_be_unmapped(mm, vma, prev, end))
|
||||
downgrade = false;
|
||||
|
||||
if (downgrade)
|
||||
mmap_write_downgrade(mm);
|
||||
|
Reference in New Issue
Block a user