Re: [PATCH] userfaultfd: prevent registration of special VMAs

From: David Hildenbrand (Arm)

Date: Thu Jun 18 2026 - 04:47:31 EST


On 6/18/26 10:43, Mike Rapoport wrote:
> On Thu, Jun 18, 2026 at 11:34:12AM +0300, Mike Rapoport wrote:
>> On Thu, Jun 18, 2026 at 10:19:17AM +0200, David Hildenbrand (Arm) wrote:
>>>
>>> I'm sure you considered VM_SPECIAL, which additionally includes VM_DONTEXPAND.
>>>
>>> Would that be better, or what was the reason to allow VM_DONTEXPAND?
>>
>> By itself VM_DONTEXPAND won't matter, as uffd can't resize a VMA.
>> But thinking more about it, it's better to make vma_can_userfault() more
>> restrictive and just use VM_SPECIAL.
>
> Ah, hugetlb sets VM_DONTEXPAND, so it must me excluded to allow uffd with
> hugetlb.
>

It would probably be cleaner to just allow hugetlb, and then check for
VM_SPECIAL if not hugetlb.

--
Cheers,

David