Skip to contentSkip to conversation

mm-mmap-properly-unaccount-memory-on-mas_preallocate-failure.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Dec 12, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/mmap: properly unaccount memory on mas_preallocate() failure
has been removed from the -mm tree. Its filename was
mm-mmap-properly-unaccount-memory-on-mas_preallocate-failure.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Alistair Popple <[email protected]>
Subject: mm/mmap: properly unaccount memory on mas_preallocate() failure
Date: Fri, 2 Dec 2022 15:53:39 +1100

security_vm_enough_memory_mm() accounts memory via a call to vm_acct_memory(). Therefore any subsequent failures should unaccount for this memory prior to returning the error.

Fixes 28c5609fb236 ("mm/mmap: preallocate maple nodes for brk vma expansion")

---

 mm/mmap.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/mmap.c renamed from mm/mmap.c~mm-mmap-properly-unaccount-memory-on-mas_preallocate-failure +3 -3
@@ -2953,7 +2953,7 @@ static int do_brk_flags(struct ma_state
 				addr >> PAGE_SHIFT, NULL_VM_UFFD_CTX, NULL)) {
 		mas_set_range(mas, vma->vm_start, addr + len - 1);
 		if (mas_preallocate(mas, vma, GFP_KERNEL))
-			return -ENOMEM;
+			goto unacct_fail;
 
 		vma_adjust_trans_huge(vma, vma->vm_start, addr + len, 0);
 		if (vma->anon_vma) {
@@ -2975,7 +2975,7 @@ static int do_brk_flags(struct ma_state
 	/* create a vma struct for an anonymous mapping */
 	vma = vm_area_alloc(mm);
 	if (!vma)
-		goto vma_alloc_fail;
+		goto unacct_fail;
 
 	vma_set_anonymous(vma);
 	vma->vm_start = addr;
@@ -3000,7 +3000,7 @@ out:
 
 mas_store_fail:
 	vm_area_free(vma);
-vma_alloc_fail:
+unacct_fail:
 	vm_unacct_memory(len >> PAGE_SHIFT);
 	return -ENOMEM;
 }

_

Patches currently in -mm which might be from [email protected] are