Re: [PATCH mm-hotfixes] mm/rmap: clear vma->anon_vma on error

From: Lorenzo Stoakes (Oracle)

Date: Wed Mar 18 2026 - 09:07:55 EST


On Wed, Mar 18, 2026 at 01:52:44PM +0100, David Hildenbrand (Arm) wrote:
>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>

Thanks!

> LGTM. I was wondering whether anon_vma_clone() should take care of
> setting up dst->anon_vma. It looks a bit odd in dup_anon_vma.

Well in the fork case we don't want to set vma->anon_vma, as we use
vma->anon_vma to denote whether or not we reused another anon_vma. For
split + remap, we already duplicated it via vm_area_dup() ->
vm_area_init_from().

But... now we have enum vma_operation threaded through here, we can just do
that there like:

/* dst is unfaulted, so inherit src's anon_vma. */
if (operation == VMA_OP_MERGE_UNFAULTED)
dst->anon_vma = src->anon_vma;

?

>
> --
> Cheers,
>
> David

Cheers, Lorenzo