Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <ljs@kernel.org>
To: Hajime Tazaki <thehajime@gmail.com>
Cc: akpm@linux-foundation.org, liam@infradead.org, vbabka@kernel.org,
	 jannh@google.com, pfalcato@suse.de, linux-mm@kvack.org,
	geert@linux-m68k.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: nommu: free unused resources when mremap shrinks the vma
Date: Fri, 10 Jul 2026 12:09:18 +0100	[thread overview]
Message-ID: <alDSyWM5SM_EjrFL@lucifer> (raw)
In-Reply-To: <m2cxwvti7z.wl-thehajime@gmail.com>

On Fri, Jul 10, 2026 at 04:30:08PM +0900, Hajime Tazaki wrote:
>
> On Fri, 10 Jul 2026 14:46:48 +0900,
> Hajime Tazaki wrote:
> >
> > When shrinking a VMA via mremap, the bounds are modified directly:
> > mm/nommu.c:do_mremap() {
> >     ...
> >     vma->vm_end = vma->vm_start + new_len;
> >     ...
> > }
> > This shrink the VMA without updating its bounds in the maple tree.
> > If the maple tree (mm->mm_mt) still contains the old bounds, a user
> > process could access the freed portion. The stale maple tree would
> > incorrectly return the shrunk VMA for an address past its new vm_end.
> >
> > This commit fixes this issue by calling vmi_shrink_vma() when shrink
> > happens.  Additionally, if a file-backed map is to be shrunk, it reports
> > -EINVAL like do_munmap() does.
> >
> > The issue is reported by Sashiko review, linked below.
> >
> > Link: https://sashiko.dev/#/patchset/20260702012546.665383-1-thehajime@gmail.com
> > Link: https://sashiko.dev/#/patchset/20260710021028.892645-1-thehajime%40gmail.com
> > Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
>
> I think the original issue reported by Sashiko is addressed, but found
> another existing issue, which might take a bit to look into detail
> (e.g., currently under nommu we cannot map (actually kernel_read())
> /dev/zero, vma_set_anonymous() isn't called for /dev/zero on nommu,
> etc).
>
> So I will address this in a different patch, not in this one.

OK thanks sorry for not getting to these quicker, between jobs atm and my inbox
is an ongoing disaster :)

>
> -- Hajime

Thanks, Lorenzo


      reply	other threads:[~2026-07-10 11:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10  5:46 [PATCH v2] mm: nommu: free unused resources when mremap shrinks the vma Hajime Tazaki
2026-07-10  7:30 ` Hajime Tazaki
2026-07-10 11:09   ` Lorenzo Stoakes [this message]

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=alDSyWM5SM_EjrFL@lucifer \
    --to=ljs@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=geert@linux-m68k.org \
    --cc=jannh@google.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pfalcato@suse.de \
    --cc=thehajime@gmail.com \
    --cc=vbabka@kernel.org \
    /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