All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Michal Hocko" <mhocko@suse.com>, "Jann Horn" <jannh@google.com>,
	"Pedro Falcato" <pfalcato@suse.de>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	"Jan Kara" <jack@suse.cz>, "Miaohe Lin" <linmiaohe@huawei.com>,
	"Naoya Horiguchi" <nao.horiguchi@gmail.com>,
	"Rik van Riel" <riel@surriel.com>, "Harry Yoo" <harry@kernel.org>,
	"Lance Yang" <lance.yang@linux.dev>,
	"Kees Cook" <kees@kernel.org>, "Zi Yan" <ziy@nvidia.com>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Nico Pache" <npache@redhat.com>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	"Dev Jain" <dev.jain@arm.com>, "Barry Song" <baohua@kernel.org>,
	"Usama Arif" <usama.arif@linux.dev>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Joshua Hahn" <joshua.hahnjy@gmail.com>,
	"Rakie Kim" <rakie.kim@sk.com>,
	"Byungchul Park" <byungchul@sk.com>,
	"Gregory Price" <gourry@gourry.net>,
	"Ying Huang" <ying.huang@linux.alibaba.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Peter Xu" <peterx@redhat.com>, "Xu Xin" <xu.xin16@zte.com.cn>,
	"Chengming Zhou" <chengming.zhou@linux.dev>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Janosch Frank" <frankja@linux.ibm.com>,
	"Claudio Imbrenda" <imbrenda@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Gerald Schaefer" <gerald.schaefer@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Boris Brezillon" <boris.brezillon@collabora.com>,
	"Steven Price" <steven.price@arm.com>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	"Huang Rui" <ray.huang@amd.com>,
	"Matthew Auld" <matthew.auld@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Oleg Nesterov" <oleg@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Jiri Olsa" <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"James Clark" <james.clark@linaro.org>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Muchun Song" <muchun.song@linux.dev>,
	"Oscar Salvador" <osalvador@suse.de>,
	"Chris Li" <chrisl@kernel.org>,
	"Kairui Song" <kasong@tencent.com>,
	"Kemeng Shi" <shikemeng@huaweicloud.com>,
	"Nhat Pham" <nphamcs@gmail.com>,
	"Baoquan He" <baoquan.he@linux.dev>,
	"Youngjun Park" <youngjun.park@lge.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org, linux-perf-users@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v4 17/20] mm/vma: only permit MAP_PRIVATE /dev/zero to be mapped anonymous
Date: Thu, 13 Aug 2026 10:36:20 +0100	[thread overview]
Message-ID: <an2PqxrAAJaEC4u2@lucifer> (raw)
In-Reply-To: <ea3c2889-343b-4eba-9758-cf56c75da4fc@kernel.org>

On Thu, Aug 13, 2026 at 11:18:13AM +0200, David Hildenbrand (Arm) wrote:
> On 8/12/26 20:05, Lorenzo Stoakes (ARM) wrote:
> > TL;DR - either we need to find a way to uniquely identify it (keep my approach
> > or move it to core mm) or we should drop this patch.
> >
> > Given we're late in the cycle + you stringly objective to my approach I think
> > maybe best to drop it and respin?
>
> Yes, let's handle that separately.

Agreed. Will respin with these bits lopped off!

>
> >
> > Can do a follow up to add unique identification later, somehow.
> >
> > The key change of 'make anon-assigned file-backed MAP_PRIVATE mappings not
> > special snowflakes' will still be achieved in the other patches (but have to
> > rework them a little obviously).
> >
> > On Wed, Aug 12, 2026 at 07:15:05PM +0200, David Hildenbrand (Arm) wrote:
> >>>
> >>> We don't assign vm_ops for a MAP_PRIVATE-/dev/zero mapping. So that won't work.
> >>>
> >>> We could expose zero->f_ops but then it's literally in drivers/char/ and that's
> >>> just weird to expose in mm.h or whatever.
> >>
> >> Thinking out loud: could we use a dummy (empty) vm_ops?
> >>
> >> We'd place it in mm.h (zero_vm_ops) and just use it in drivers/char/.
> >
> > The entire purpose of this patch is to _uniquely identify_ MAP_PRIVATE-mapped
> > /dev/zero and only permit this to make a mapping anonymous.
> >
> > As per the commit message: 'mm/vma: only permit MAP_PRIVATE /dev/zero to be
> > mapped anonymous'
> >
> > MAP_PRIVATE-/dev/zero to anon is a historical abberation. This is why it is a
> > unique case where semantics don't make sense.
> >
> > Doing things by semantics makes sense if the semantics are a _class_ of
> > thing. This is not a class of thing it is a one of one.
> >
> > Yes the method used is ugly, but the alternatives (I can think of) are:
> >
> > 1. (your proposal) allow any in-tree non-module mmap_prepare() driver to map
> >    anonymous pages, creating an entirely new semantic for memory mapping.
> >
> >    (this is currently something that is possible, unfortunately).
> >
> >    To be safe we would have to implement then a series of checks to prevent true
> >    insanities, because doing that would permit broken madness like a PFN map
> >    being treated as anon.
> >
> >    Once this stuff is out there as an API, even in-tree, even non-module, people
> >    will abuse it because it'll go through some random tree and we'll have to
> >    support it.
> >
> >    I mean we may as well just not make a change in this case other than maybe
> >    preventing .mmap from being able to do this.
>
> As discussed off-list, we could have in in mm/ and special-case
> drivers/char/mem.c to include a mm header like fs/exec.c similarly does.
>
> drivers/char/mem.c really belongs to core-mm.

Yeah, there's no approach that won't involve something gross but it's a case of
least-worst.

As per my MAINTAINERS change putting drivers/char/mem.c in mm sections also
(first step at least :) I agree very much that it's a core mm thing or at least
large chunks of it.

>
> >
> > 2. My solution - ugly but uniquely identifies the single permitted situation
> >    where this behaviour is desired.
> >
> > 3. Export something from drivers/char/mem.c to mm - horrific for multiple
> >    reasons, violates separation of concerns etc. etc.
>
> Jup.
>
> >
> > 4. Move the driver code just for /dev/zero to mm - I thought a pretty horrible
> >    idea, but maybe we could have some mm/ bit and some driver/char bit like
> >    hugetlbfs or uffd? But I'm not sure there is a not-ugly way of doing this.
> >    MAP_SHARED /dev/zero does shmem stuff so maybe could live there.
>
> Given that I think drivers/char/mem.c really is core-mm material, something
> along these lines also make sense.

Yeah, the devil's in the details but the /dev/zero stuff can be dealt with next
cycle.

Respin incoming!

>
> --
> Cheers,
>
> David

--
Cheers, Lorenzo

  reply	other threads:[~2026-08-13  9:36 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 20:21 [PATCH v4 00/20] mm/rmap: index MAP_PRIVATE file-backed folios by anonymous pgoff Lorenzo Stoakes (ARM)
2026-08-06 20:21 ` [PATCH v4 01/20] mm/vma: introduce VMA anon page offset field and add helpers Lorenzo Stoakes (ARM)
2026-08-09  0:51   ` Suren Baghdasaryan
2026-08-10  8:36     ` Lorenzo Stoakes (ARM)
2026-08-10 16:24       ` Suren Baghdasaryan
2026-08-06 20:21 ` [PATCH v4 02/20] mm: provide vma_[flags_]is_cow_mapping() and remove is_cow_mapping() Lorenzo Stoakes (ARM)
2026-08-10 17:59   ` Lorenzo Stoakes (ARM)
2026-08-10 22:10     ` Andrew Morton
2026-08-11  8:40       ` Lorenzo Stoakes (ARM)
2026-08-11 16:14       ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 03/20] mm: introduce linear_anon_page_index() Lorenzo Stoakes (ARM)
2026-08-09  0:49   ` Suren Baghdasaryan
2026-08-10  8:39     ` Lorenzo Stoakes (ARM)
2026-08-10 16:25       ` Suren Baghdasaryan
2026-08-11 16:19   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 04/20] mm: abstract vma_address() and introduce vma_anon_address() Lorenzo Stoakes (ARM)
2026-08-06 20:21 ` [PATCH v4 05/20] mm: update print_bad_page_map() to show anon index if appropriate Lorenzo Stoakes (ARM)
2026-08-06 20:21 ` [PATCH v4 06/20] mm: introduce and use vma_filebacked_address() Lorenzo Stoakes (ARM)
2026-08-06 20:21 ` [PATCH v4 07/20] mm/vma: fix self-merge check in copy_vma() Lorenzo Stoakes (ARM)
2026-08-11 16:44   ` David Hildenbrand (Arm)
2026-08-11 16:51     ` Lorenzo Stoakes (ARM)
2026-08-11 16:53       ` David Hildenbrand (Arm)
2026-08-11 17:06         ` Lorenzo Stoakes (ARM)
2026-08-06 20:21 ` [PATCH v4 08/20] tools/testing/vma: add tests for copy_vma() self-merge Lorenzo Stoakes (ARM)
2026-08-11 16:46   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 09/20] mm: propagate VMA anonymous page offset on map, remap, split + merge Lorenzo Stoakes (ARM)
2026-08-06 20:21 ` [PATCH v4 10/20] mm/rmap: track whether the page VMA mapped pgoff is anonymous Lorenzo Stoakes (ARM)
2026-08-11 16:46   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 11/20] mm: clean up vma_address_end() Lorenzo Stoakes (ARM)
2026-08-11 16:48   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 12/20] mm/huge_memory: update remove_migration_pmd() to accept a folio Lorenzo Stoakes (ARM)
2026-08-11 16:49   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 13/20] mm/migrate: calculate large folio page index using PFN Lorenzo Stoakes (ARM)
2026-08-11 16:49   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 14/20] mm/rmap: use anon pgoff to track MAP_PRIVATE file-backed anon folios Lorenzo Stoakes (ARM)
2026-08-11 16:52   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 15/20] tools/testing/vma: expand VMA merge tests to assert anon pgoff Lorenzo Stoakes (ARM)
2026-08-11 16:53   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 16/20] tools/testing/selftests/mm: test anonymous page offset merge behaviour Lorenzo Stoakes (ARM)
2026-08-11 16:56   ` David Hildenbrand (Arm)
2026-08-11 17:07     ` Lorenzo Stoakes (ARM)
2026-08-11 20:08       ` Andrew Morton
2026-08-12 17:24         ` Lorenzo Stoakes (ARM)
2026-08-06 20:21 ` [PATCH v4 17/20] mm/vma: only permit MAP_PRIVATE /dev/zero to be mapped anonymous Lorenzo Stoakes (ARM)
2026-08-11 17:07   ` David Hildenbrand (Arm)
2026-08-11 19:25     ` Lorenzo Stoakes (ARM)
2026-08-12 17:15       ` David Hildenbrand (Arm)
2026-08-12 18:05         ` Lorenzo Stoakes (ARM)
2026-08-13  9:18           ` David Hildenbrand (Arm)
2026-08-13  9:36             ` Lorenzo Stoakes (ARM) [this message]
2026-08-06 20:21 ` [PATCH v4 18/20] mm/vma: make MAP_PRIVATE-mapped /dev/zero mappings truly anonymous Lorenzo Stoakes (ARM)
2026-08-13  9:29   ` David Hildenbrand (Arm)
2026-08-13  9:34     ` Lorenzo Stoakes (ARM)
2026-08-06 20:21 ` [PATCH v4 19/20] tools/testing/vma: add test to assert MAP_PRIVATE-/dev/zero is anon Lorenzo Stoakes (ARM)
2026-08-12 17:17   ` David Hildenbrand (Arm)
2026-08-12 18:08     ` Lorenzo Stoakes (ARM)
2026-08-12 17:18   ` David Hildenbrand (Arm)
2026-08-06 20:21 ` [PATCH v4 20/20] tools/testing/selftests/mm: add MAP_PRIVATE-/dev/zero merge tests Lorenzo Stoakes (ARM)
2026-08-06 23:27 ` [PATCH v4 00/20] mm/rmap: index MAP_PRIVATE file-backed folios by anonymous pgoff Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=an2PqxrAAJaEC4u2@lucifer \
    --to=ljs@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=agordeev@linux.ibm.com \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.deucher@amd.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=apopple@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=boris.brezillon@collabora.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=byungchul@sk.com \
    --cc=chengming.zhou@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=frankja@linux.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gourry@gourry.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=harry@kernel.org \
    --cc=hca@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=irogers@google.com \
    --cc=jack@suse.cz \
    --cc=james.clark@linaro.org \
    --cc=jannh@google.com \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=jolsa@kernel.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kasong@tencent.com \
    --cc=kees@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mark.rutland@arm.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=mripard@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=namhyung@kernel.org \
    --cc=nao.horiguchi@gmail.com \
    --cc=npache@redhat.com \
    --cc=nphamcs@gmail.com \
    --cc=oleg@redhat.com \
    --cc=osalvador@suse.de \
    --cc=peterx@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pfalcato@suse.de \
    --cc=rakie.kim@sk.com \
    --cc=ray.huang@amd.com \
    --cc=riel@surriel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=surenb@google.com \
    --cc=svens@linux.ibm.com \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tzimmermann@suse.de \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=willy@infradead.org \
    --cc=xu.xin16@zte.com.cn \
    --cc=ying.huang@linux.alibaba.com \
    --cc=youngjun.park@lge.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.