All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Puranjay Mohan <puranjay12@gmail.com>,
	 Pedro Falcato <pfalcato@suse.de>, Ingo Molnar <mingo@redhat.com>,
	 Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	 Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	 Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	 Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	 Kees Cook <kees@kernel.org>,
	David Hildenbrand <david@kernel.org>,
	 "Liam R. Howlett" <liam@infradead.org>,
	Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
	 Shakeel Butt <shakeel.butt@linux.dev>,
	Jann Horn <jannh@google.com>,
	 Alexei Starovoitov <ast@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 bpf@vger.kernel.org, Chris Mason <mason@kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] mm/vma: drop mm asynchronously in vma_start_read()
Date: Tue, 24 Nov 2026 18:51:12 +0000	[thread overview]
Message-ID: <awXbVeK7F2DmgL-9@gremlin> (raw)
In-Reply-To: <498284d2-70e4-4b6e-978b-98a2b9e1e74d@kernel.org>

On Tue, Nov 24, 2026 at 07:35:39PM +0100, Vlastimil Babka (SUSE) wrote:
> On 11/24/26 18:49, Suren Baghdasaryan wrote:
> > On Tue, Nov 24, 2026 at 9:33 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> >>
> >> On Tue, 24 Nov 2026 17:23:35 +0000 "Lorenzo Stoakes (ARM)" <ljs@kernel.org> wrote:
> >>
> >> > On Tue, Nov 24, 2026 at 08:34:40AM -0800, Suren Baghdasaryan wrote:
> >> > > On Tue, Nov 24, 2026 at 8:06 AM Puranjay Mohan <puranjay12@gmail.com> wrote:
> >> > > >
> >> > > > On Tue, Nov 24, 2026 at 9:28 PM Lorenzo Stoakes (ARM) <ljs@kernel.org> wrote:
> >> > > > >
> >> > > > > On Tue, Nov 24, 2026 at 07:51:42AM -0800, Suren Baghdasaryan wrote:
> >> > > > > > Actually, VMAs are allocated from a SLAB_TYPESAFE_BY_RCU slub. With
> >> > > > > > that RCU unlocking move you don't need other_mm copy and the comment
> >> > > > > > that comes with it. VMA won't be freed until RCU lock is dropped.
> >> > > > >
> >> > > > > Yeah but they can be reassigned? They won't be _freed_ until a grace period but
> >> > > > > they can go back to the slab and then allocated elsewhere  right?
> >> > > > >
> >> > > >
> >> > > > Yes, they can go back to the slab and become a different VMA.
> >> > >
> >> > > Yeah, you are right about that. So, we either have to keep the RCU
> >> > > unlock in place to keep other_mm comment valid (my personal
> >> > > preference) or update the comment next to other_mm to explain the new
> >> > > reason it is needed. Either way is fine with me.
> >> >
> >> > I think let's just change the comment?
> >> >
> >> > Andrew could you change:
> >> >
> >> >        * stable and can be freed in the narrow window after vma->vm_refcnt
> >> >
> >> > ->
> >> >
> >> >        * stable and can be reused in the narrow window after vma->vm_refcnt
> >> >                            ^
> >> >                            |
> >> >                            just this freed -> reused :)
> >> >
> >>
> >> np.
> >>
> >> --- a/mm/mmap_lock.c~mm-vma-drop-mm-asynchronously-in-vma_start_read-fix
> >> +++ a/mm/mmap_lock.c
> >> @@ -300,7 +300,7 @@ err:
> >>  err_unstable:
> >>         /*
> >>          * If vma got attached to another mm from under us, that mm is not
> >> -        * stable and can be freed in the narrow window after vma->vm_refcnt
> >> +        * stable and can be reused in the narrow window after vma->vm_refcnt
>
> But this is talking about the mm, not the vma, so the motivation to change
> that was wrong? (it's not a typesafe cache). Moreover...
>
> >>          * is dropped and before rcuwait_wake_up(mm) is called. Grab it before
> >>          * releasing vma->vm_refcnt.
> >>          */
> >
> > Sorry for being pedantic :)
> > There is also this comment later on:
> >
> >         other_mm = vma->vm_mm; /* use a copy as vma can be freed after
> > we drop vm_refcnt */
> >
> > That should be replaced too with:
> >
> >         other_mm = vma->vm_mm; /* use a copy as vma can be reused
> > after we drop vm_refcnt */
> >
> > Again, just replacing "freed" to "reused".
>
> Nah let's not overthink this. It's freed back to the allocator first. Which
> naturally allows it to be reused, yes. It doesn't matter if the underlying
> page can be freed or not. UAF is a UAF.

Let me just send a v2 that puts the rcu_read_unlock() back where it was, I don't
really want to get into some long debate about nitpicky details. I just have too
much to do sorry.

--
Cheers, Lorenzo

  reply	other threads:[~2026-11-24 18:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 12:26 [PATCH] mm/vma: drop mm asynchronously in vma_start_read() Lorenzo Stoakes (ARM)
2026-11-24 13:04 ` Pedro Falcato
2026-11-24 15:46   ` Suren Baghdasaryan
2026-11-24 15:51     ` Suren Baghdasaryan
2026-11-24 15:58       ` Lorenzo Stoakes (ARM)
2026-11-24 16:05         ` Puranjay Mohan
2026-11-24 16:34           ` Suren Baghdasaryan
2026-11-24 17:23             ` Lorenzo Stoakes (ARM)
2026-11-24 17:33               ` Andrew Morton
2026-11-24 17:49                 ` Suren Baghdasaryan
2026-11-24 18:35                   ` Vlastimil Babka (SUSE)
2026-11-24 18:51                     ` Lorenzo Stoakes (ARM) [this message]
2026-12-02  3:44                   ` [folded-merged] mm-vma-drop-mm-asynchronously-in-vma_start_read-fix-2.patch removed from -mm tree Andrew Morton
2026-11-24 17:33               ` + mm-vma-drop-mm-asynchronously-in-vma_start_read-fix.patch added to mm-hotfixes-unstable branch Andrew Morton
2026-12-02  3:43               ` [folded-merged] mm-vma-drop-mm-asynchronously-in-vma_start_read-fix.patch removed from -mm tree Andrew Morton
2026-11-24 15:56     ` [PATCH] mm/vma: drop mm asynchronously in vma_start_read() Lorenzo Stoakes (ARM)
2026-11-24 17:13 ` + mm-vma-drop-mm-asynchronously-in-vma_start_read.patch added to mm-hotfixes-unstable branch Andrew Morton
2026-11-24 18:37 ` [PATCH] mm/vma: drop mm asynchronously in vma_start_read() Vlastimil Babka (SUSE)
2026-12-02  3:47 ` [merged mm-hotfixes-stable] mm-vma-drop-mm-asynchronously-in-vma_start_read.patch removed from -mm tree 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=awXbVeK7F2DmgL-9@gremlin \
    --to=ljs@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=bsegall@google.com \
    --cc=david@kernel.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=jannh@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kees@kernel.org \
    --cc=kprateek.nayak@amd.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mason@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pfalcato@suse.de \
    --cc=puranjay12@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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.