Re: [PATCH] mm/memory: Fix missing pte marker for !page on pte zaps

From: David Hildenbrand
Date: Wed Mar 13 2024 - 18:26:46 EST


On 13.03.24 23:03, David Hildenbrand wrote:
On 13.03.24 22:31, peterx@xxxxxxxxxx wrote:
From: Peter Xu <peterx@xxxxxxxxxx>

Commit 0cf18e839f64 of large folio zap work broke uffd-wp. Now mm's uffd
unit test "wp-unpopulated" will trigger this WARN_ON_ONCE().

Good that I added the WARN_ON_ONCE() :)


The WARN_ON_ONCE() asserts that an VMA cannot be registered with
userfaultfd-wp if it contains a !normal page, but it's actually possible.
One example is an anonymous vma, register with uffd-wp, read anything will
install a zero page. Then when zap on it, this should trigger.

Are you sure? zap_install_uffd_wp_if_needed() contains right at the start:

/* Zap on anonymous always means dropping everything */
if (vma_is_anonymous(vma))
return;

So if that's the case the unit test triggers, I'm confused.


Ah, got it. It's not that we have to place a marker, just that it can happen. Of course it can. All makes sense.

Thanks!

--
Cheers,

David / dhildenb