Skip to contentSkip to conversation

mm/damon/vaddr: check address space stability before VMA traversal

PATCH In review Igor Putko 2 participants 2 messages Jun 30 – Jul 1

Subsystems (2)
lore
Share & tools
lore

Igor Putko

author
#0 lore raw

PATCH 1/1 mm/damon/vaddr: check address space stability before VMA traversal

In __damon_va_three_regions(), the VMA tree is traversed without checking if the address space is stable. If the OOM reaper runs concurrently, it may mark the mm as MMF_UNSTABLE and leave empty markers in the maple tree.
Add a check_stable_address_space(mm) call before iterating over the VMAs to avoid potential NULL pointer dereferences.

---
 mm/damon/vaddr.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/damon/vaddr.c +4 -0
index 345b89b5d..e756ac147 100644
@@ -11,6 +11,7 @@
 #include <linux/hugetlb.h>
 #include <linux/mman.h>
 #include <linux/mmu_notifier.h>
+#include <linux/oom.h>
 #include <linux/page_idle.h>
 #include <linux/pagewalk.h>
 #include <linux/sched/mm.h>
@@ -84,6 +85,9 @@ static int __damon_va_three_regions(struct mm_struct *mm,
 	 * If this is too slow, it can be optimised to examine the maple
 	 * tree gaps.
 	 */
+	if (!check_stable_address_space(mm))
+		return -EINVAL;
+
 	for_each_vma(vmi, vma) {
 		unsigned long gap;
 
Signature · 1 line
2.47.3
maintainer
#1 lore raw
Quoted 4 lines · On Tue, 30 Jun 2026 18:25:58 +0300 Igor Putko <[email protected]> wrote:

In __damon_va_three_regions(), the VMA tree is traversed without checking if the address space is stable. If the OOM reaper runs concurrently, it may mark the mm as MMF_UNSTABLE and leave empty markers in the maple tree.

I initially thought this is correct, but... Hasn't the series starting from commit bed76bec3111 ("mm: relocate the page table ceiling and floor definitions") fixed the issue?

Thanks,
SJ

[...]