Re: [RFC PATCH v3 4/8] mm/gup: break out follow_one_pte() helper
From: Yuan-Hao Hsu
Date: Sun Oct 18 2026 - 14:29:14 EST
On Fri, 28 Aug 2026 22:11:07 -0400, Rik van Riel wrote:
> On Fri, 2026-08-28 at 16:47 -0700, Suren Baghdasaryan wrote:
> > 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.
That exit is reached with a present PTE: follow_one_pte() has already
returned 0 for !pte_present() above it, and pte_none() is false for
any present PTE.
So "!ret && pte_none(pte)" in follow_page_pte() can only be true on
the !pte_present() path, and the old "goto no_page; if
(!pte_none(pte)) return 0;" sent exactly that case to no_page_table()
as well.
The can_follow_write_pte() and pte_protnone() exits still end in a
plain return 0, as before. No functional change here, so nothing to
fix for v4.
Yuan-Hao Hsu