mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
mm/vma: don't leak the charge for stack growth
acct_stack_growth() charges stack expansion even without VM_ACCOUNT.
This can happen for read-only or MAP_NORESERVE mappings created with
MAP_GROWSDOWN. Unmapping these VMAs does not release the charge, leaking
Committed_AS.
Only check and charge growth for VM_ACCOUNT VMAs, matching mremap().
Unaccounted growth skips the overcommit check while remaining subject
to the other stack-growth limits.
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Reported-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Reviewed-by: Harry Yoo (Meta) <harry@kernel.org>
Tested-by: Muhammad Usama Anjum <usama.anjum@arm.com>
Link: https://patch.msgid.link/20261031-fixes_core-v3-44-d6437171ecc3@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
This commit is contained in:
parent
23e5709274
commit
b1ee878021
3
mm/vma.c
3
mm/vma.c
|
|
@ -3391,7 +3391,8 @@ static int acct_stack_growth(struct vm_area_struct *vma,
|
|||
* Overcommit.. This must be the final test, as it will
|
||||
* update security statistics.
|
||||
*/
|
||||
if (security_vm_enough_memory_mm(mm, grow))
|
||||
if (vma_test(vma, VMA_ACCOUNT_BIT) &&
|
||||
security_vm_enough_memory_mm(mm, grow))
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user