if (brk < min_brk)
goto out;
+
/*
* Check against rlimit here. If this check is done later after the test
* of oldbrk with newbrk then it can escape the test and let the data
if (populate)
mm_populate(oldbrk, newbrk - oldbrk);
return brk;
-
out:
mmap_write_unlock(mm);
return origbrk;
return nr_pages;
}
-static void __vma_link_file(struct vm_area_struct *vma)
+static void __vma_link_file(struct vm_area_struct *vma,
+ struct address_space *mapping)
{
- struct file *file;
-
- file = vma->vm_file;
- if (file) {
- struct address_space *mapping = file->f_mapping;
-
- if (vma->vm_flags & VM_SHARED)
- mapping_allow_writable(mapping);
+ if (vma->vm_flags & VM_SHARED)
+ mapping_allow_writable(mapping);
- flush_dcache_mmap_lock(mapping);
- vma_interval_tree_insert(vma, &mapping->i_mmap);
- flush_dcache_mmap_unlock(mapping);
- }
+ flush_dcache_mmap_lock(mapping);
+ vma_interval_tree_insert(vma, &mapping->i_mmap);
+ flush_dcache_mmap_unlock(mapping);
}
/*
}
vma_mas_store(vma, &mas);
- __vma_link_file(vma);
- if (mapping)
+ if (mapping) {
+ __vma_link_file(vma, mapping);
i_mmap_unlock_write(mapping);
+ }
mm->map_count++;
validate_mm(mm);
uprobe_munmap(next, next->vm_start, next->vm_end);
i_mmap_lock_write(mapping);
- if (insert) {
+ if (insert && insert->vm_file) {
/*
* Put into interval tree now, so instantiated pages
* are visible to arm/parisc __flush_dcache_page
* throughout; but we cannot insert into address
* space until vma start or end is updated.
*/
- __vma_link_file(insert);
+ __vma_link_file(insert, insert->vm_file->f_mapping);
}
}
struct mm_struct *mm = current->mm;
validate_mm_mt(mm);
+
/*
* Check against address space limits by the changed size
* Note: This happens *after* clearing old mappings in some code paths.
goto mas_store_fail;
mm->map_count++;
+
out:
perf_event_mmap(vma);
mm->total_vm += len >> PAGE_SHIFT;