Skip to contentSkip to conversation

mm-nommu-add-sysctl_max_map_count-check-for-do_mmap.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jul 31

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: nommu: add sysctl_max_map_count() check for do_mmap()
has been removed from the -mm tree. Its filename was
mm-nommu-add-sysctl_max_map_count-check-for-do_mmap.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: Hajime Tazaki <[email protected]>
Subject: mm: nommu: add sysctl_max_map_count() check for do_mmap()
Date: Thu, 2 Jul 2026 10:28:30 +0900

The sysctl variable vm.max_map_count (sysctl_max_map_count) is not exposed under !MMU configurations, but its default value (DEFAULT_MAX_MAP_COUNT) is still used as a allocation limit. Currently, this limit is enforced when a VMA entry is split into two chunks (split_vma()), but it is not checked during initial allocation (do_mmap()). As a result, if a user requests a large number of memory allocations, the system will continue allocating until it hits an Out-Of-Memory (OOM) condition.

This commit introduces a check at the beginning of do_mmap() in nommu.c to prevent this situation.

This issue was detected using the Linux Test Project (LTP) test linked below.

---

 mm/nommu.c |    3 +++
 1 file changed, 3 insertions(+)
mm/nommu.c renamed from mm/nommu.c~mm-nommu-add-sysctl_max_map_count-check-for-do_mmap +3 -0
@@ -1035,6 +1035,9 @@ unsigned long do_mmap(struct file *file,
 	if (ret < 0)
 		return ret;
 
+	if (current->mm->map_count >= get_sysctl_max_map_count())
+		return -ENOMEM;
+
 	/* we ignore the address hint */
 	addr = 0;
 	len = PAGE_ALIGN(len);

_

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

mm-nommu-point-to-the-write-iterator-upon-split_vma.patch mm-nommu-fix-the-error-path-when-vma_iter_prealloc-fails.patch