mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Gregory Price <gourry@gourry.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 "Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	 David Hildenbrand <david@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>, Will Deacon <will@kernel.org>,
	 "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>,
	Nick Piggin <npiggin@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
	 Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	 "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Jan Kara <jack@suse.cz>, Marc Zyngier <maz@kernel.org>,
	 Oliver Upton <oupton@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	 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>,
	"David S. Miller" <davem@davemloft.net>,
	 Andreas Larsson <andreas@gaisler.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	 Christian Brauner <brauner@kernel.org>,
	Matthew Brost <matthew.brost@intel.com>,
	 Chengming Zhou <chengming.zhou@linux.dev>,
	Michal Hocko <mhocko@kernel.org>,
	 Miklos Szeredi <miklos@szeredi.hu>, Xu Xin <xu.xin@linux.dev>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 01/40] mm/vma: fix mmap_prepare file handling, remove file_doesnt_need_get
Date: Fri, 25 Sep 2026 10:30:45 +0100	[thread overview]
Message-ID: <arY7e_4p27Mic7bH@gremlin> (raw)
In-Reply-To: <arVOW_frpIU_JbbP@gourry-fedora-PF4VCD3F>

On Thu, Sep 24, 2026 at 12:28:39PM -0400, Gregory Price wrote:
> On Thu, Sep 17, 2026 at 05:22:10PM +0100, Lorenzo Stoakes (ARM) wrote:
> > +static void put_map(struct mmap_state *map)
> > +{
> ...
> > +	if (map->vm_file && !map_same_file(map))
> > +		fput(map->vm_file);
> ...
> > diff --git a/mm/vma.h b/mm/vma.h
> > index e97bd2dfa786..f15faa83f3d6 100644
> > --- a/mm/vma.h
> > +++ b/mm/vma.h
> > @@ -394,8 +394,10 @@ static inline void compat_set_vma_from_desc(struct vm_area_struct *vma,
> >
> > +	if (desc->vm_file != vma->vm_file) {
> > +		fput(vma->vm_file);
>
>
> Sashiko pointed out that this could be null if the vma is "anonymized".

Sashiko is wrong :) I wish I could mark responses like that so it didn't
regenerate them on each respin.

(I always run sashiko output received for each series through a frontier
LLM anyway + fix stuff that is real, see the changelog for series for those
things that were valid)

You can't reach this code without a vma->vm_file.

>
> Previously we'd discussed that anonymizing a file folio is more of a
> wart than a feature, and IIRC you intended to remove that (i think?)
> when you removed zero-file mapping "anonymization" so some of this VMA
> stuff could be detangled.

The anonymising as existed before clears vma->vm_ops not vma->vm_file.

The new _actual_ anonymisation for MAP_PRIVATE-/dev/zero clears
vma->vm_file but only on the raw mmap_prepare non-compat path, stacked
MAP_PRIVATE-/dev/zero is not supported as a means of getting anonymous
memory (and would be a really strange thing to do anyway).

(In general stacked file systems only operate on regular files anyway).

>
> If this is an intermediate state, do we still need to manage this NULL
> scenario, and when we drop the anonymization mechanism we add a WARN()
> that says someone is being naughty?

Nope not at all.

No code path can get here with NULL vm_file and it's already the case that
a driver setting the wrong thing NULL could trigger a NULL pointer deref
anyway.

Nothing in-tree does anything like this and out of tree drivers can trigger
stuff if they want but it's not for us to worry about (they already can do
that locally :P) :)

>
> ~Gregory

--
Cheers, Lorenzo

  reply	other threads:[~2026-09-25  9:30 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 16:22 [PATCH v3 00/40] mm: make VMA flag semantics explicit, eliminate VM_SPECIAL Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 01/40] mm/vma: fix mmap_prepare file handling, remove file_doesnt_need_get Lorenzo Stoakes (ARM)
2026-09-23 15:21   ` Suren Baghdasaryan
2026-09-23 15:46     ` Lorenzo Stoakes (ARM)
2026-09-23 15:59       ` Suren Baghdasaryan
2026-09-24  2:20   ` Zi Yan
2026-09-24 10:03     ` Lorenzo Stoakes (ARM)
2026-09-24 16:28   ` Gregory Price
2026-09-25  9:30     ` Lorenzo Stoakes (ARM) [this message]
2026-09-24 19:00   ` Liam R. Howlett
2026-09-25  9:12     ` Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 02/40] mm/vma: predicate setting mmap_prepare VMA fields on new vma alloc Lorenzo Stoakes (ARM)
2026-09-23 15:32   ` Suren Baghdasaryan
2026-09-23 15:53     ` Lorenzo Stoakes (ARM)
2026-09-23 16:09       ` Suren Baghdasaryan
2026-09-23 17:07         ` Lorenzo Stoakes (ARM)
2026-09-23 17:33   ` Lorenzo Stoakes (ARM)
2026-09-24  2:25   ` Zi Yan
2026-09-17 16:22 ` [PATCH v3 03/40] mm/vma: introduce and use vma_[flags_]can_merge() Lorenzo Stoakes (ARM)
2026-09-23 16:23   ` Suren Baghdasaryan
2026-09-24  2:27   ` Zi Yan
2026-09-24 16:38   ` Gregory Price
2026-09-17 16:22 ` [PATCH v3 04/40] mm: consistently validate VMA state after mmap[_prepare] hooks Lorenzo Stoakes (ARM)
2026-09-23 16:47   ` Suren Baghdasaryan
2026-09-23 17:00     ` Lorenzo Stoakes (ARM)
2026-09-24  2:52   ` Zi Yan
2026-09-24 10:06     ` Lorenzo Stoakes (ARM)
2026-09-24 17:17   ` Gregory Price
2026-09-17 16:22 ` [PATCH v3 05/40] mm/vma: ensure mmap_prepare doesn't set actions on a mergeable vma Lorenzo Stoakes (ARM)
2026-09-24 18:00   ` Gregory Price
2026-09-25  9:51     ` Lorenzo Stoakes (ARM)
2026-09-24 19:28   ` Zi Yan
2026-09-25  9:55     ` Lorenzo Stoakes (ARM)
2026-09-25  7:28   ` Suren Baghdasaryan
2026-09-25  9:53     ` Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 06/40] mm: make map_kernel_pages_[prepare,complete] internal and unexported Lorenzo Stoakes (ARM)
2026-09-24 19:30   ` Zi Yan
2026-09-25  7:35     ` Suren Baghdasaryan
2026-09-17 16:22 ` [PATCH v3 07/40] mm/vma: tidy up map kernel pages enum values Lorenzo Stoakes (ARM)
2026-09-24 19:30   ` Zi Yan
2026-09-25  7:37     ` Suren Baghdasaryan
2026-09-17 16:22 ` [PATCH v3 08/40] mm: add mmap action for discontiguous kernel page mapping Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 09/40] docs: filesystems: update mmap_prepare docs for discontig kernel pgs Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 10/40] drivers/usb/mon: update to use mmap_prepare + map kernel pages Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 11/40] infiniband: update hfi1 to use remap_vmalloc_range() Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 12/40] selinux: reject writable opens of policy file, drop mmap shared/write check Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 13/40] ALSA: pcm: use vm_insert_page() to map PCM status page Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 14/40] bpf: arena: mark arena_map_mmap() mappings VM_MIXEDMAP Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 15/40] mm/vma: add vma[_flags]_is_kernel_owned() predicates Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 16/40] mm/vma: only allow mmap to clear VMA_MAYWRITE_BIT if kernel-owned Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 17/40] mm/vma: add and use vma_[flags]_is_fixed_mapping Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 18/40] scsi: sg: convert mmap hook to mmap_prepare and rework Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 19/40] fbdev: defio: assert FBINFO_VIRTFB, drop VM_IO, add VM_MIXEDMAP Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 20/40] HSI: cmt_speech: convert mmap hook to mmap_prepare, refactor Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 21/40] mm/gup: error out early on !VMA_MAYREAD_BIT VMAs Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 22/40] uprobes: remove VM_IO, set VM_MIXEDMAP for mapped kernel pages Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 23/40] mm/mlock: clear VMA_LOCKED_MASK over mmap callback Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 24/40] mm/mlock: eliminate weird VMA_IO_BIT abuse and simplify Lorenzo Stoakes (ARM)
2026-09-23 20:06   ` Zi Yan
2026-09-24 10:21     ` Lorenzo Stoakes (ARM)
2026-09-24 15:50       ` Zi Yan
2026-09-25  9:35         ` Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 25/40] mm/vma: enforce that only kernel-owned mappings may set VMA_IO_BIT Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 26/40] mm: remove VMA_IO_BIT check in vma[_flags]_is_kernel_owned() Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 27/40] mm: remove hugetlb_inline.h Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 28/40] mm: rename is_vm_hugetlb_page() to vma_is_hugetlb() Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 29/40] mm: drop some redundant checks around hugetlb VMAs Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 30/40] mm/madvise: update is_valid_guard_vma() to use vma_can_merge() Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 31/40] mm/vma: introduce vma[_flags]_is_persistent() Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 32/40] mm/uffd: use predicates for userfaultfd checks Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 33/40] mm/madvise: use predicates for madvise(..., MADV_DOFORK) Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 34/40] mm: eliminate VMA_SPECIAL_FLAGS usage when hugetlb explicitly tested Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 35/40] mm: eliminate VMA_SPECIAL_FLAGS check in lru_gen_look_around() Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 36/40] mm: avoid use of VMA_SPECIAL_FLAGS in migrate_vma_setup() Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 37/40] mm: eliminate VM_SPECIAL, VMA_SPECIAL_FLAGS Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 38/40] fuse: dax: do not set VM_MIXEDMAP Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 39/40] mm/huge_memory: remove vma_is_special_huge() Lorenzo Stoakes (ARM)
2026-09-17 16:22 ` [PATCH v3 40/40] mm/vma: introduce and use vma[_flags]_can_gup() Lorenzo Stoakes (ARM)
2026-09-17 21:23 ` [PATCH v3 00/40] mm: make VMA flag semantics explicit, eliminate VM_SPECIAL Andrew Morton
2026-09-23  8:57 ` Lorenzo Stoakes (ARM)

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=arY7e_4p27Mic7bH@gremlin \
    --to=ljs@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreas@gaisler.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=borntraeger@linux.ibm.com \
    --cc=brauner@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=chengming.zhou@linux.dev \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=frankja@linux.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gourry@gourry.net \
    --cc=hca@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=jack@suse.cz \
    --cc=liam@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.brost@intel.com \
    --cc=maz@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mripard@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=npiggin@gmail.com \
    --cc=osalvador@suse.de \
    --cc=oupton@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=rppt@kernel.org \
    --cc=tzimmermann@suse.de \
    --cc=vbabka@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will@kernel.org \
    --cc=willy@infradead.org \
    --cc=xu.xin@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®