Re: [PATCH v2] mm/gup: disallow GUP writing to file-backed mappings by default

From: Lorenzo Stoakes
Date: Mon Apr 24 2023 - 19:27:22 EST


On Mon, Apr 24, 2023 at 08:17:11PM -0300, Jason Gunthorpe wrote:
> On Tue, Apr 25, 2023 at 12:03:34AM +0100, Lorenzo Stoakes wrote:
>
> > Except you dirty a page that is mapped elsewhere that thought everything
> > was cleaned and... not sure the PTLs really help you much?
>
> If we have a writable PTE then while the PTE's PTL is held it is impossible
> for a FS to make the page clean as any cleaning action has to also
> take the PTL to make the PTE non-present or non-writable.
>

That's a very good point! Passing things back with a spinlock held feels
pretty icky though, and obviously a no-go for a FOLL_PIN. Perhaps for a
FOLL_GET this would be workable.

> > If we want to be more adventerous the opt-in variant could default to on
> > for FOLL_LONGTERM too, but that discussion can be had over on that patch
> > series.
>
> I think you should at least do this too to explain why io_uring code
> is moving into common code..
>

OK, I'll respin this as a v3 of this series then since we'll be defaulting
FOLL_LONGTERM at least (for which there seems to be broad consensus), but
also permit this flag to be set manually and set it for io_uring.

> Jason