Re: [PATCH RFC 05/12] mm/gup: Fix follow_devmap_p[mu]d() to return even if NULL

Peter Xu
2023-11-23T17:59:37Z

On Wed, Nov 22, 2023 at 11:25:28PM -0800, Christoph Hellwig wrote:
> On Wed, Nov 15, 2023 at 08:29:01PM -0500, Peter Xu wrote:
> > This seems to be a bug not by any report but by code observations.
> >
> > When GUP sees a devpmd or devpud, it should return whatever value returned
> > from follow_devmap_p[mu]d(). If page==NULL returned, it means a fault is
> > probably required. Skipping return the NULL should allow the code to fall
> > through, which can cause unexpected behavior.
> >
> > It was there at least before the follow page rework (080dbb618b) in 2017,
> > so 6 years. Not yet digging for a Fixes, assuming it can hardly trigger
> > even if the logical bug does exist.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
>
> I'd still add a fixes tag and send if off to Linux for 6.7-rc instead
> of letting it linger.

Will do.

>
> Otherwise looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

When rethinking, "return page" is correct for devmap, but it should be
better to always use no_page_table() instead for page==NULL when trying to
return NULL for follow_page(), even if no_page_table() should constantly
return NULL for devmap, afaict, so it should be the same.

So I'll make it slightly different when reposting separately, please feel
free to have another look.

Thanks,

--
Peter Xu