Re: [RFC PATCH v3 4/8] mm/gup: break out follow_one_pte() helper

From: Rik van Riel

Date: Fri Aug 28 2026 - 22:11:38 EST


On Fri, 2026-08-28 at 16:47 -0700, Suren Baghdasaryan wrote:
> On Mon, Aug 10, 2026 at 8:07 PM Rik van Riel <riel@xxxxxxxxxxx>
> wrote:
> >
> >
> >         /*
> >          * We only care about anon pages in can_follow_write_pte().
> >          */
> > -       if ((flags & FOLL_WRITE) &&
> > -           !can_follow_write_pte(pte, page, vma, flags)) {
> > -               ret = 0;
> > -               goto out;
> > -       }
> > +       if ((flags & FOLL_WRITE) && !can_follow_write_pte(pte,
> > page, vma, flags))
> > +               return 0;
>
> Before refactoring in the above case we would "goto out" and
> no_page_table() would not be called even if pte_none(pte). Now I
> think
> you will call it if pte_none(pte). I'm not sure if this does not
> matter but this seems like a functional change.

Good catch, now we may end up calling no_page_table()
on a VMA where we are not allowed to write, for a
FOLL_WRITE access, while before we did not.

That might turn 0 into -EFAULT in some corner cases.

I don't know if we can actually hit any of those
corner cases, or whether they matter in practice,
but the fix seems easy enough, so I'll fix it for v4.

--
All Rights Reversed.