Skip to content

Commit 13d77e0

Browse files
howlettakpm00
authored andcommitted
mm/mmap: use vms accounted pages in mmap_region()
Change from nr_pages variable to vms.nr_accounted for the charged pages calculation. This is necessary for a future patch. This also avoids checking security_vm_enough_memory_mm() if the amount of memory won't change. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Liam R. Howlett <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Reviewed-by: Suren Baghdasaryan <[email protected]> Acked-by: Paul Moore <[email protected]> [LSM] Cc: Kees Cook <[email protected]> Cc: Bert Karwatzki <[email protected]> Cc: Jeff Xu <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Mark Brown <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Sidhartha Kumar <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5972d97 commit 13d77e0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mm/mmap.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1414,9 +1414,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
14141414
*/
14151415
if (accountable_mapping(file, vm_flags)) {
14161416
charged = pglen;
1417-
charged -= nr_accounted;
1418-
if (security_vm_enough_memory_mm(mm, charged))
1417+
charged -= vms.nr_accounted;
1418+
if (charged && security_vm_enough_memory_mm(mm, charged))
14191419
goto abort_munmap;
1420+
14201421
vms.nr_accounted = 0;
14211422
vm_flags |= VM_ACCOUNT;
14221423
}

0 commit comments

Comments
 (0)