[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZEWOwz/82AKHGrXW@kernel.org>
Date: Sun, 23 Apr 2023 22:02:11 +0200
From: Simon Horman <horms@...nel.org>
To: Lorenzo Stoakes <lstoakes@...il.com>
Cc: Simon Horman <simon.horman@...igine.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Jason Gunthorpe <jgg@...pe.ca>, 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
Subject: Re: [PATCH] mm/gup: disallow GUP writing to file-backed mappings by
default
On Sun, Apr 23, 2023 at 08:40:53PM +0100, Lorenzo Stoakes wrote:
> On Sun, Apr 23, 2023 at 09:32:01PM +0200, Simon Horman wrote:
> > On Sat, Apr 22, 2023 at 02:37:05PM +0100, Lorenzo Stoakes wrote:
> > > It isn't safe to write to file-backed mappings as GUP does not ensure that
> > > the semantics associated with such a write are performed correctly, for
> > > instance filesystems which rely upon write-notify will not be correctly
> > > notified.
> > >
> > > There are exceptions to this - shmem and hugetlb mappings are (in effect)
> > > anonymous mappings by other names so we do permit this operation in these
> > > cases.
> > >
> > > In addition, if no pinning takes place (neither FOLL_GET nor FOLL_PIN is
> > > specified and neither flags gets implicitly set) then no writing can occur
> > > so we do not perform the check in this instance.
> > >
> > > This is an important exception, as populate_vma_page_range() invokes
> > > __get_user_pages() in this way (and thus so does __mm_populate(), used by
> > > MAP_POPULATE mmap() and mlock() invocations).
> > >
> > > There are GUP users within the kernel that do nevertheless rely upon this
> > > behaviour, so we introduce the FOLL_ALLOW_BROKEN_FILE_MAPPING flag to
> > > explicitly permit this kind of GUP access.
> > >
> > > This is required in order to not break userspace in instances where the
> > > uAPI might permit file-mapped addresses - a number of RDMA users require
> > > this for instance, as do the process_vm_[read/write]v() system calls,
> > > /proc/$pid/mem, ptrace and SDT uprobes. Each of these callers have been
> > > updated to use this flag.
> > >
> > > Making this change is an important step towards a more reliable GUP, and
> > > explicitly indicates which callers might encouter issues moving forward.
> >
> > nit: s/encouter/encounter/
> >
>
> Ack, I always seem to leave at least one or two easter egg spelling
> mistakes in :)
:)
> Will fix up on next respin (in unlikely event of no further review,
> hopefully Andrew would pick up!)
>
Powered by blists - more mailing lists