All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: David CARLIER <devnexen@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Heechan Kang <gganji11@naver.com>,
	"Liam R. Howlett" <liam@infradead.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Michael Bommarito <michael.bommarito@gmail.com>,
	Peter Xu <peterx@redhat.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] userfaultfd: refuse to __mfill_atomic_pte() for unsupported VMAs
Date: Thu, 28 May 2026 10:33:12 +0300	[thread overview]
Message-ID: <ahfvuAdJs8zhzkTF@kernel.org> (raw)
In-Reply-To: <CA+XhMqy6NH6Nn0=jT7Js6nAe-8UbZbhpTCoP5gSBsODpAMfqnQ@mail.gmail.com>

On Wed, May 27, 2026 at 08:09:01PM +0100, David CARLIER wrote:
> Hi,
> 
> just chiming it
> 
> On Wed, 27 May 2026 at 19:48, Mike Rapoport <rppt@kernel.org> wrote:
> >
> > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> >
> > __mfill_atomic_pte() unconditionally dereferences ops because there is an
> > assumption that VMAs that can undergo mfill_* operations are vetted on
> > registration and must have valid vm_uffd_ops.
> >
> > Add a guard against potential bugs and make sure __mfill_atomic_pte() bails
> > out if ops is NULL.
> >
> > Suggested-by: Lorenzo Stoakes <ljs@kernel.org>
> > Fixes: ad9ac3081332 ("userfaultfd: introduce vm_uffd_ops->alloc_folio()")
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> > ---
> >  mm/userfaultfd.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
> > index e5d2fb3ce2c1..2872c71bbf36 100644
> > --- a/mm/userfaultfd.c
> > +++ b/mm/userfaultfd.c
> > @@ -552,6 +552,11 @@ static int __mfill_atomic_pte(struct mfill_state *state,
> >         struct folio *folio;
> >         int ret;
> >
> > +       if (!ops) {
> > +               VM_WARN_ONCE(1, "UFFDIO_COPY for unsupported VMA");
> 
> nit: Is the warning message a bit too specific ? i.e. Also handle
> MFILL_ATOMIC_ZEROPAGE case.

It handles ZEROPAGE case by actually copying a zeroed page there so in a
sense it's still a copy.

Differentiating COPY and ZEROPAGE here will add complexity that is not
justified for a message that should be never printed.
 
> > +               return -EOPNOTSUPP;
> > +       }
> > +
> >         folio = ops->alloc_folio(state->vma, state->dst_addr);
> >         if (!folio)
> >                 return -ENOMEM;
> > --
> > 2.53.0
> >
> 
> Cheers.
> 

-- 
Sincerely yours,
Mike.


  reply	other threads:[~2026-05-28  7:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27 18:47 [PATCH v2 0/3] userfaultfd: verify VMA state across UFFDIO_COPY retry Mike Rapoport
2026-05-27 18:47 ` [PATCH v2 1/3] " Mike Rapoport
2026-05-28 13:31   ` Lorenzo Stoakes
2026-05-28 14:41     ` Mike Rapoport
2026-05-28 21:04       ` Andrew Morton
2026-06-08 13:03       ` Lorenzo Stoakes
2026-06-08 16:39         ` Andrew Morton
2026-06-08 18:57           ` Mike Rapoport
2026-05-27 18:47 ` [PATCH v2 2/3] userfaultfd: refuse to __mfill_atomic_pte() for unsupported VMAs Mike Rapoport
2026-05-27 19:09   ` David CARLIER
2026-05-28  7:33     ` Mike Rapoport [this message]
2026-05-28  7:34       ` David CARLIER
2026-05-28 13:11   ` Lorenzo Stoakes
2026-05-27 18:47 ` [PATCH v2 3/3] userfaultfd: remove redundant check in vm_uffd_ops() Mike Rapoport
2026-05-28 13:10   ` Lorenzo Stoakes

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=ahfvuAdJs8zhzkTF@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=devnexen@gmail.com \
    --cc=gganji11@naver.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=michael.bommarito@gmail.com \
    --cc=peterx@redhat.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.