DAMON development mailing list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: tao <tao.wangtao@honor.com>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH v2 09/13] mm: prepare anon_node replacement for ANON_VMA_FRACTAL
Date: Tue, 07 Jul 2026 09:12:24 +0000	[thread overview]
Message-ID: <20260707091224.E5ACA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707063308.29176-10-tao.wangtao@honor.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Lockless traversal of the shared `fractal_list` in `anon_node_verify()` leads to data races and potential use-after-free.
- [Low] Using `#if CONFIG_DEBUG_VM_RB` instead of `#ifdef` causes `-Wundef` compilation warnings when the config is disabled.
--

--- Patch [9]: [RFC PATCH v2 09/13] mm: prepare anon_node replacement for ANON_VMA_FRACTAL ---
commit 7ac3c97b907c3a50c0e59be4fc5c3a22d3833da9
Author: tao <tao.wangtao@honor.com>
    
mm: prepare anon_node replacement for ANON_VMA_FRACTAL

This commit introduces macros in vma.c to isolate code differences and
split the large code changes into smaller patches for the anon_node
replacement in ANON_VMA_FRACTAL.

> diff --git a/mm/vma.c b/mm/vma.c
> index d2996369e30d6..02178112daa0b 100644
> --- a/mm/vma.c
> +++ b/mm/vma.c

[ ... ]

> @@ -675,12 +675,19 @@ void validate_mm(struct mm_struct *mm)
>  			vma_iter_dump_tree(&vmi);
>  		}
>  
> -#ifdef CONFIG_DEBUG_VM_RB
> -		if (anon_vma) {
> +#if CONFIG_DEBUG_VM_RB

[Severity: Low]
Does this introduce a -Wundef compiler warning when the config is disabled?

Since CONFIG_DEBUG_VM_RB is a boolean option, it is left undefined rather
than set to 0 when disabled. Using #if instead of #ifdef might cause
build failures when compiling with -Werror.

> +		if (vma->anon_vma) {
> +#ifdef CONFIG_ANON_VMA_FRACTAL
> +			anon_node_verify((void *)vma->anon_vma);

[Severity: Medium]
Can this cause a data race or use-after-free by locklessly iterating over
the fractal_list?

In the legacy path below, anon_vma_lock_read() is explicitly acquired
before traversing the list. However, anon_node_verify() iterates over
the shared anon_node tree using anon_node_next_rbc_child() without
taking anon_node_lock_rmap().

Since the anon_node structure is shared across multiple processes after
fork(), could another process concurrently modify the fractal_list while
validate_mm() is traversing it?

> +#else
> +			struct anon_vma *anon_vma = vma->anon_vma;
> +			struct anon_vma_chain *avc;
> +
>  			anon_vma_lock_read(anon_vma);
>  			list_for_each_entry(avc, &vma->anon_vma_chain, same_vma)
>  				anon_vma_interval_tree_verify(avc);
>  			anon_vma_unlock_read(anon_vma);
> +#endif
>  		}
>  #endif

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707063308.29176-1-tao.wangtao@honor.com?part=9

  reply	other threads:[~2026-07-07  9:12 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  6:32 [RFC PATCH v2 00/13] mm: rework anon_vma and remove anon_vma_chain tao
2026-07-07  6:32 ` [RFC PATCH v2 01/13] mm: add CONFIG_ANON_VMA_FRACTAL tao
2026-07-07  7:11   ` sashiko-bot
2026-07-07  6:32 ` [RFC PATCH v2 02/13] mm: implement helpers for ANON_VMA_FRACTAL tao
2026-07-07  7:23   ` sashiko-bot
2026-07-07  6:32 ` [RFC PATCH v2 03/13] mm: implement __anon_node_prepare " tao
2026-07-07  7:39   ` sashiko-bot
2026-07-07  6:32 ` [RFC PATCH v2 04/13] mm: implement anon_node_clone " tao
2026-07-07  8:00   ` sashiko-bot
2026-07-07  6:33 ` [RFC PATCH v2 05/13] mm: implement anon_node_fork_with_prev " tao
2026-07-07  8:22   ` sashiko-bot
2026-07-07  6:33 ` [RFC PATCH v2 06/13] mm: implement unlink_anon_nodes " tao
2026-07-07  6:33 ` [RFC PATCH v2 07/13] mm: handle rmap_base changes " tao
2026-07-07  8:45   ` sashiko-bot
2026-07-07  6:33 ` [RFC PATCH v2 08/13] mm: implement anonymous folio rmap " tao
2026-07-07  9:01   ` sashiko-bot
2026-07-07  6:33 ` [RFC PATCH v2 09/13] mm: prepare anon_node replacement " tao
2026-07-07  9:12   ` sashiko-bot [this message]
2026-07-07  6:33 ` [RFC PATCH v2 10/13] mm: replace anon_vma with anon_node " tao
2026-07-07  9:25   ` sashiko-bot
2026-07-07  6:33 ` [RFC PATCH v2 11/13] mm: optimize rmap for ANON_VMA_FRACTAL with PVL tao
2026-07-07  9:41   ` sashiko-bot
2026-07-07  6:33 ` [RFC PATCH v2 12/13] mm: shared semaphores for ANON_VMA_FRACTAL tao
2026-07-07  9:59   ` sashiko-bot
2026-07-07  6:33 ` [RFC PATCH v2 13/13] mm: Enable CONFIG_ANON_VMA_FRACTAL by default tao
2026-07-07 10:21   ` sashiko-bot
2026-07-07  7:01 ` [RFC PATCH v2 00/13] mm: rework anon_vma and remove anon_vma_chain David Hildenbrand (Arm)
2026-07-07  8:21   ` wangtao
2026-07-07  8:31     ` David Hildenbrand (Arm)
2026-07-07  9:20       ` wangtao
2026-07-07 16:19         ` Gregory Price
2026-07-07 17:09         ` David Hildenbrand (Arm)
2026-07-08  3:26           ` wangtao
2026-07-08  8:18             ` David Hildenbrand (Arm)
2026-07-07  9:07     ` Pedro Falcato
2026-07-07 15:27 ` Borislav Petkov
2026-07-07 21:32 ` [syzbot ci] " syzbot ci

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=20260707091224.E5ACA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tao.wangtao@honor.com \
    /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