All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Linus Torvalds <torvalds@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: mm-commits@vger.kernel.org, vladimirelitokarev@gmail.com,
	viro@zeniv.linux.org.uk, stable@vger.kernel.org,
	peterx@redhat.com, oleg@redhat.com, jack@suse.cz,
	brauner@kernel.org, rppt@kernel.org
Subject: Re: + userfaultfd-prevent-registration-of-special-vmas.patch added to mm-hotfixes-unstable branch
Date: Thu, 18 Jun 2026 23:07:13 +0200	[thread overview]
Message-ID: <9bbaa053-ea06-4b36-98ba-dc487a28964e@kernel.org> (raw)
In-Reply-To: <CAHk-=wiQ_10MRYYW+aRfLP4Ah9gDrShOvLESXtz+Q32-9M9Y9w@mail.gmail.com>

On 6/18/26 21:25, Linus Torvalds wrote:
> On Thu, 18 Jun 2026 at 11:34, Andrew Morton <akpm@linux-foundation.org> wrote:
>>
>> Since VM_SPECIAL includes VM_DONTEXPAND which is set but hugetlb, exclude
>> hugetlb VMAs from the check for VM_SPECIAL.
> 
> This seems bogus.
> 
> If somebody sets DONTEXPAND, then that mapping *is* special, and
> userfaultfd should not mess with it.

Right, it's one kind of special.

> 
> It feels like hugetlbfs is just wrong to do this.
> 
> This has caused problems before, see MADV_DODUMP which has that same
> "hugetlb doesn't follow the rules" check.
> 
> What exactly is it that hugetlbfs wants that DONTEXPAND thing to be?

I tried digging into the history: hugetlb doesn't support VMA merging (or VMA
expansion through mremap), apparently because of hugetlb reservation
interactions. Just nasty.

So I guess for userfaultd at least the VMA mergability/expansion doesn't matter.
Hopefully.

> 
> That said, I don't like the VM_SPECIAL bit mask all that much, because
> it doesn't specify *what* kind of "special" it is.

Right. It's documented as

	"Special vmas that are non-mergable, non-mlock()able."

It's a bit weird that we throw both things into one bin but ok.

And we use it in other context, like

	#define VM_NO_KHUGEPAGED (VM_SPECIAL | VM_HUGETLB)


Maybe we should rename and possibly split that up, like

	VM_NO_MLOCK
	VM_NO_VMA_MERGE

And then have some generic "there are really special things mapped in here"

	VM_HAS_SPECIAL_MAPPINGS


This might become a bigger (overdue?) audit, because I wouldn't immediately be
able to tell why MLOCK would have a problem with VM_DONTEXPAND.

VMA_REMAP_FLAGS is also odd, because it talks about "Physically remapped pages
are special" but then also includes VM_DONTEXPAND.

Any suggestion?

-- 
Cheers,

David

  reply	other threads:[~2026-06-18 21:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 18:34 + userfaultfd-prevent-registration-of-special-vmas.patch added to mm-hotfixes-unstable branch Andrew Morton
2026-06-18 19:25 ` Linus Torvalds
2026-06-18 21:07   ` David Hildenbrand (Arm) [this message]
2026-06-18 21:42     ` Linus Torvalds
2026-06-19  7:53       ` David Hildenbrand (Arm)
  -- strict thread matches above, loose matches on Subject: below --
2026-06-17 19:45 Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9bbaa053-ea06-4b36-98ba-dc487a28964e@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=mm-commits@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linuxfoundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vladimirelitokarev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.