[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZEa+L5ivNDhCmgj4@nvidia.com>
Date: Mon, 24 Apr 2023 14:36:47 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Lorenzo Stoakes <lstoakes@...il.com>
Cc: Christoph Hellwig <hch@...radead.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Jens Axboe <axboe@...nel.dk>,
Matthew Wilcox <willy@...radead.org>,
Dennis Dalessandro <dennis.dalessandro@...nelisnetworks.com>,
Leon Romanovsky <leon@...nel.org>,
Christian Benvenuti <benve@...co.com>,
Nelson Escobar <neescoba@...co.com>,
Bernard Metzler <bmt@...ich.ibm.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Bjorn Topel <bjorn@...nel.org>,
Magnus Karlsson <magnus.karlsson@...el.com>,
Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
Jonathan Lemon <jonathan.lemon@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Christian Brauner <brauner@...nel.org>,
Richard Cochran <richardcochran@...il.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
linux-fsdevel@...r.kernel.org, linux-perf-users@...r.kernel.org,
netdev@...r.kernel.org, bpf@...r.kernel.org,
Oleg Nesterov <oleg@...hat.com>
Subject: Re: [PATCH v2] mm/gup: disallow GUP writing to file-backed mappings
by default
On Mon, Apr 24, 2023 at 03:29:57PM +0100, Lorenzo Stoakes wrote:
> On Mon, Apr 24, 2023 at 10:39:25AM -0300, Jason Gunthorpe wrote:
> > On Mon, Apr 24, 2023 at 01:38:49PM +0100, Lorenzo Stoakes wrote:
> >
> > > I was being fairly conservative in that list, though we certainly need to
> > > set the flag for /proc/$pid/mem and ptrace to avoid breaking this
> > > functionality (I observed breakpoints breaking without it which obviously
> > > is a no go :). I'm not sure if there's a more general way we could check
> > > for this though?
> >
> > More broadly we should make sure these usages of GUP safe somehow so
> > that it can reliably write to those types of pages without breaking
> > the current FS contract..
> >
> > I forget exactly, but IIRC, don't you have to hold some kind of page
> > spinlock while writing to the page memory?
> >
>
> I think perhaps you're thinking of the mm->mmap_lock? Which will be held
> for the FOLL_GET cases and simply prevent the VMA from disappearing below
> us but not do much else.
No not mmap_lock, I want to say there is a per-page lock that
interacts with the write protect, or at worst this needs to use the
page table spinlocks.
> I wonder whether we should do this check purely for FOLL_PIN to be honest?
> As this indicates medium to long-term access without mmap_lock held. This
> would exclude the /proc/$pid/mem and ptrace paths which use gup_remote().
Everything is buggy. FOLL_PIN is part of a someday solution to solve
it.
> That and a very specific use of uprobes are the only places that use
> FOLL_GET in this instance and each of them are careful in any case to
> handle setting the dirty page flag.
That is actually the bug :) Broadly the bug is to make a page dirty
without holding the right locks to actually dirty it.
Jason
Powered by blists - more mailing lists