From: Mike Rapoport <rppt@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linuxfoundation.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Oleg Nesterov <oleg@redhat.com>, Peter Xu <peterx@redhat.com>,
vova tokarev <vladimirelitokarev@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
stable@vger.kernel.org
Subject: Re: [PATCH] userfaultfd: prevent registration of special VMAs
Date: Thu, 18 Jun 2026 11:34:05 +0300 [thread overview]
Message-ID: <ajOtfdGgFQYL-T6f@kernel.org> (raw)
In-Reply-To: <5a993689-f730-406d-8515-8bb6025cc851@kernel.org>
On Thu, Jun 18, 2026 at 10:19:17AM +0200, David Hildenbrand (Arm) wrote:
> On 6/17/26 21:40, Mike Rapoport wrote:
> > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> >
> > Vova Tokarev says:
> >
> > userfaultfd allows registration on shadow stack VMAs. With userfaultfd
> > access, you can register on the shadow stack, discard a page ... and
> > inject a page with chosen return addresses via UFFDIO_COPY.
> >
> > Update vma_can_userfault() to reject VM_SHADOW_STACK.
> >
> > While on it, also reject VM_IO, VM_MIXEDMAP and VM_PFNMAP so that if a
> > driver would implement vm_uffd_ops, it wouldn't be possible to register
> > special VMAs with userfaultfd.
> >
> > Reported-by: vova tokarev <vladimirelitokarev@gmail.com>
> > Fixes: 54007f818206 ("mm: Introduce VM_SHADOW_STACK for shadow stack memory")
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> > ---
> > mm/userfaultfd.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
> > index 246af12bf801..b8d2d87ce8d7 100644
> > --- a/mm/userfaultfd.c
> > +++ b/mm/userfaultfd.c
> > @@ -2111,7 +2111,8 @@ static bool vma_can_userfault(struct vm_area_struct *vma, vm_flags_t vm_flags,
> > {
> > const struct vm_uffd_ops *ops = vma_uffd_ops(vma);
> >
> > - if (vma->vm_flags & VM_DROPPABLE)
> > + if (vma->vm_flags & (VM_DROPPABLE | VM_IO | VM_MIXEDMAP | VM_PFNMAP |
> > + VM_SHADOW_STACK))
>
> 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.
> --
> Cheers,
>
> David
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-06-18 8:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 19:40 [PATCH] userfaultfd: prevent registration of special VMAs Mike Rapoport
2026-06-18 8:19 ` David Hildenbrand (Arm)
2026-06-18 8:34 ` Mike Rapoport [this message]
2026-06-18 8:43 ` Mike Rapoport
2026-06-18 8:47 ` David Hildenbrand (Arm)
2026-06-18 9:21 ` Mike Rapoport
2026-06-18 9:25 ` David Hildenbrand (Arm)
2026-06-18 9:35 ` Mike Rapoport
2026-06-18 9:37 ` David Hildenbrand (Arm)
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=ajOtfdGgFQYL-T6f@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david@kernel.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
--cc=peterx@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox