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

Jason Gunthorpe
2023-04-24T22:53:39Z

On Mon, Apr 24, 2023 at 08:18:33PM +0100, Lorenzo Stoakes wrote:

> I think this patch suggestion has scope crept from 'incremental
> improvement' to 'major rework of GUP' at this point.

I don't really expect to you clean up all the callers - but we are
trying to understand what is actually wrong here to come up with the
right FOLL_ names and overall strategy. Leave behind a comment, for
instance.

I don't think anyone has really thought about the ptrace users too
much till now, we were all thinking about DMA use cases, it shows we
still have some areas that need attention.

> Also surely you'd want to obtain the PTL of all mappings to a file?

No, just one is fine. If you do the memcpy under a single PTL that
points at a writable copy of the page then everything is trivially
fine because it is very similar to what the CPU itself would do, which
is fine by definition..

Jason