Re: [PATCH] mm/vma: read anon_vma carefully in validate_mm()
From: Pedro Falcato
Date: Mon Nov 02 2026 - 05:36:11 EST
On Mon, Nov 02, 2026 at 10:25:20AM +0000, Lorenzo Stoakes (ARM) wrote:
> Commit 38564710f443 ("mm: implement and use vma_has_anon_rmap(), silence
> KCSAN") rather clumsily converted the read of vma->anon_vma into a
> vma_has_anon_rmap() without accounting for the separation between
> assignment of anon_vma and later use of it.
>
> vma_has_anon_rmap() is intended as an optimistic check, so doesn't need to
> protect against a torn read in vma->anon_vma. The caller is expected to
> take care of this themselves if they then in fact access the field.
>
> validate_mm() does indeed then reference the field, so resolve the issue
> via READ_ONCE(), and simplify the code by separating this into a new
> function validate_mm_anon_rmap().
>
> Finally, add a vma_assert_stabilised() to make it clear the required state
> of the VMA.
>
> Fixes: 38564710f443 ("mm: implement and use vma_has_anon_rmap(), silence KCSAN")
> Reported-by: syzbot+10e72ea5747737bcd2ad@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://lore.kernel.org/all/6ae78418.6552420f.2a0efc.005c.GAE@xxxxxxxxxx/
> Reported-by: Songsen Yang <yangsongsen@xxxxxxxxxxxx>
> Closes: https://lore.kernel.org/all/20261102074414.10902-1-yangsongsen@xxxxxxxxxxxx/
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
Reviewed-by: Pedro Falcato <pfalcato@xxxxxxx>
--
Pedro