Skip to content

Commit

Permalink
Revert "mm/mmap: drop range_has_overlap() function"
Browse files Browse the repository at this point in the history
This reverts commit 30cbc90.
  • Loading branch information
xanmod committed Oct 21, 2022
1 parent 7f88072 commit 4b946cd
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,30 @@ anon_vma_interval_tree_post_update_vma(struct vm_area_struct *vma)
anon_vma_interval_tree_insert(avc, &avc->anon_vma->rb_root);
}

/*
* range_has_overlap() - Check the @start - @end range for overlapping VMAs and
* sets up a pointer to the previous VMA
* @mm: the mm struct
* @start: the start address of the range
* @end: the end address of the range
* @pprev: the pointer to the pointer of the previous VMA
*
* Returns: True if there is an overlapping VMA, false otherwise
*/
static inline
bool range_has_overlap(struct mm_struct *mm, unsigned long start,
unsigned long end, struct vm_area_struct **pprev)
{
struct vm_area_struct *existing;

MA_STATE(mas, &mm->mm_mt, start, start);
rcu_read_lock();
existing = mas_find(&mas, end - 1);
*pprev = mas_prev(&mas, 0);
rcu_read_unlock();
return existing ? true : false;
}

static unsigned long count_vma_pages_range(struct mm_struct *mm,
unsigned long addr, unsigned long end)
{
Expand Down Expand Up @@ -3151,10 +3175,11 @@ void exit_mmap(struct mm_struct *mm)
*/
int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
{
struct vm_area_struct *prev;
unsigned long charged = vma_pages(vma);


if (find_vma_intersection(mm, vma->vm_start, vma->vm_end))
if (range_has_overlap(mm, vma->vm_start, vma->vm_end, &prev))
return -ENOMEM;

if ((vma->vm_flags & VM_ACCOUNT) &&
Expand Down

0 comments on commit 4b946cd

Please sign in to comment.