DAMON development mailing list
 help / color / mirror / Atom feed
From: Igor Putko <igorpetindev@gmail.com>
To: sj@kernel.org
Cc: akpm@linux-foundation.org, damon@lists.linux.dev,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Igor Putko <igorpetindev@gmail.com>
Subject: [PATCH] mm/damon/vaddr: check address space stability before VMA traversal
Date: Tue, 30 Jun 2026 18:25:58 +0300	[thread overview]
Message-ID: <20260630152558.24063-1-igorpetindev@gmail.com> (raw)

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.

Signed-off-by: Igor Putko <igorpetindev@gmail.com>
---
 mm/damon/vaddr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index 345b89b5d..e756ac147 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -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;
 
-- 
2.47.3


                 reply	other threads:[~2026-06-30 15:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260630152558.24063-1-igorpetindev@gmail.com \
    --to=igorpetindev@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox