Re: [PATCH 11/12] mm/madvise: send UFFD_EVENT_REMOVE when installing guard regions
From: Jose A. Perez de Azpillaga
Date: Thu Nov 12 2026 - 05:09:40 EST
On 11/12/26 12:21 AM, Tal Zussman wrote:
> + Jose
>
> On 11/11/26 2:25 PM, Kiryl Shutsemau wrote:
>> On Wed, Nov 11, 2026 at 12:55:19PM -0500, Tal Zussman wrote:
>>> On an anonymous VMA, the zap drops uffd-wp and RWP protection along with
>>> the pages. Writes and accesses to the range after the guard is removed
>>> are then not reported, and the manager cannot know that it has to
>>> protect the range again.
>>
>> For RWP this only holds if the range is registered without MISSING.
>>
>> The zap frees the pages, so with MISSING the first access after the
>> guard is removed is reported as a missing fault. And there is nothing to
>> protect again: RWP only covers present PTEs, and a page faulted back in
>> shows up as accessed in PAGEMAP_SCAN.
>>
> So this makes sense, but I think this gets at the documentation point
> raised in the other thread. It seems that to use sync RWP "properly" it
> needs to be combined with MINOR for shmem and hugetlb (and MISSING for
> holes) and with MISSING for anonymous memory. Is that accurate? If so,
> this should be stated much more explicitly in the documentation + man
> page. I see that co-registering with MISSING is mentioned, but not the
> rest of the points (reclaim, collapse, etc.) The example in
> userfaultfd.rst also registers a MAP_SHARED mapping only with RWP and
> MISSING, no MINOR, so that should be clarified too. Hopefully this will
> make it into Jose's documentation patch.
okay, if Kiryl is okay with that I will add it to my upcoming patch.
--
cheers,
jose a. p-a