[PATCH OLK-6.6] mm/vma: don't leak the charge for stack growth
From: "David Hildenbrand (Arm)" <david@kernel.org> stable inclusion from stable-v6.6.163 commit bbe903084b7dfdce65c605f94dc298c7eaaa9d9f category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/21541 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=... -------------------------------- [ Upstream commit b1ee87802111156e27557e82acc31fa7dfc76e2a ] 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: 1da177e4c3f4 ("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> [ sashal: Replaced vma_test(vma, VMA_ACCOUNT_BIT) with a direct vma->vm_flags & VM_ACCOUNT check. ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Yi Yang <yiyang13@huawei.com> --- mm/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index bb21bb960f27..777b61d3d644 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2084,7 +2084,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->vm_flags & VM_ACCOUNT) && + security_vm_enough_memory_mm(mm, grow)) return -ENOMEM; return 0; -- 2.25.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/31562 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/7OC... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/31562 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/7OC...
participants (2)
-
patchwork bot -
Yi Yang