All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Igor Putko" <igorpetindev@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH v2] mm/damon/vaddr: remove redundant RCU lock
Date: Tue, 30 Jun 2026 13:16:09 +0000	[thread overview]
Message-ID: <20260630131611.D6D9C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630130253.3843-1-igorpetindev@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] VMA iteration on an external mm_struct is performed without checking check_stable_address_space(mm), which can lead to iterating a corrupted maple tree.
--

commit fdc4435ee0611e8373511ef284a90ecc98420eec
Author: Igor Putko <igorpetindev@gmail.com>

mm/damon/vaddr: remove redundant RCU lock

This commit removes rcu_read_lock() and rcu_read_unlock() from
__damon_va_three_regions() and adds them to its kunit test. It asserts that
mmap_read_lock() is sufficient to protect the maple tree during VMA iteration.

> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index e73ec1ce016e5..882cc7cb09027 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c

[ ... ]

> @@ -82,7 +82,6 @@ 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.
>  	 */
> -	rcu_read_lock();
>  	for_each_vma(vmi, vma) {

[Severity: High]
This is a pre-existing issue, but while reviewing the VMA traversal here,
I noticed a potential problem with how the mmap_read_lock is used by the
callers of this function.

When traversing VMAs on an external mm_struct, does this code need to check
check_stable_address_space(mm) before iterating? 

Looking at damon_va_three_regions() and damon_va_walk_page_range(), they
acquire mmap_read_lock(mm) and proceed directly to VMA traversal:

mm/damon/vaddr.c:damon_va_three_regions() {
	...
	mmap_read_lock(mm);
	rc = __damon_va_three_regions(mm, regions);
	mmap_read_unlock(mm);
	...
}

If the OOM reaper runs on the target process, it can mark the mm as unstable
and leave XA_ZERO_ENTRY markers in the maple tree. Iterating this corrupted
tree without first verifying check_stable_address_space(mm) can lead to
kernel crashes.

Could this be triggered under system memory pressure while DAMON is
monitoring?

>  		unsigned long gap;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260630130253.3843-1-igorpetindev@gmail.com?part=1

  reply	other threads:[~2026-06-30 13:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 16:53 [PATCH] mm/damon/vaddr: remove redundant RCU lock IgorpetinDev
2026-06-29 17:06 ` sashiko-bot
2026-06-30  0:41   ` SJ Park
2026-06-30  1:00 ` SJ Park
2026-06-30 12:50   ` IgorpetinDev
2026-06-30 13:01 ` Igor Putko
2026-06-30 13:16   ` sashiko-bot
2026-06-30 13:02 ` [PATCH v2] " Igor Putko
2026-06-30 13:16   ` sashiko-bot [this message]
2026-06-30 14:03   ` SJ Park
2026-06-30 13:07 ` [PATCH] " Igor Putko
2026-06-30 13:54   ` SJ Park
2026-06-30 14:25 ` Igor Putko
2026-06-30 14:50   ` SJ Park

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=20260630131611.D6D9C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=igorpetindev@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.