]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mm/huge_memory: check pmd_special() only after pmd_present()
authorDavid Hildenbrand <david@redhat.com>
Thu, 26 Sep 2024 15:42:34 +0000 (17:42 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 9 Oct 2024 19:47:19 +0000 (12:47 -0700)
commit47fa30118f02dc50e1c57242c6b72542c871b178
treee2ad21ea7396c4b0ad95cc718b329d1fe1fa1843
parent0665d7a39bdf92c8ac3dc390501f303907c87f62
mm/huge_memory: check pmd_special() only after pmd_present()

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.

Link: https://lkml.kernel.org/r/20240926154234.2247217-1-david@redhat.com
Fixes: bc02afbd4d73 ("mm/fork: accept huge pfnmap entries")
Signed-off-by: David Hildenbrand <david@redhat.com>
Reported-by: syzbot+bf2c35fa302ebe3c7471@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/lkml/66f15c8d.050a0220.c23dd.000f.GAE@google.com/
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c