Re: [PATCH v1] mm/huge_memory: check pmd_special() only after pmd_present()

From: Peter Xu
Date: Thu Sep 26 2024 - 11:59:52 EST


On Thu, Sep 26, 2024 at 05:42:34PM +0200, David Hildenbrand wrote:
> We should only check for pmd_special() after we made sure that we
> have a present PMD. For example, if we have a migration PMD,
> pmd_special() might indicate that we have a special PMD although we
> really don't.
>
> This fixes confusing migration entries as PFN mappings, and not
> doing what we are supposed to do in the "is_swap_pmd()" case further
> down in the function -- including messing up COW, page table handling
> and accounting.
>
> Reported-by: syzbot+bf2c35fa302ebe3c7471@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://lore.kernel.org/lkml/66f15c8d.050a0220.c23dd.000f.GAE@xxxxxxxxxx/
> Fixes: bc02afbd4d73 ("mm/fork: accept huge pfnmap entries")
> Cc: Peter Xu <peterx@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>

Reviewed-by: Peter Xu <peterx@xxxxxxxxxx>

--
Peter Xu