From: Hajime Tazaki <thehajime@gmail.com>
To: akpm@linux-foundation.org, liam@infradead.org, ljs@kernel.org,
vbabka@kernel.org, jannh@google.com, pfalcato@suse.de,
linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: nommu: fix the error path when vma_iter_prealloc() fails
Date: Mon, 06 Jul 2026 11:49:58 +0900 [thread overview]
Message-ID: <m2pl10u90p.wl-thehajime@gmail.com> (raw)
In-Reply-To: <c8513ee5aa8444ec9bf6c276043c9f833016a2fa.1783304131.git.thehajime@gmail.com>
On Mon, 06 Jul 2026 11:18:46 +0900,
Hajime Tazaki wrote:
>
> When vma_iter_prealloc() fails, it jumps to error_just_free without
> updating ret to -ENOMEM, meaning do_mmap() will return 0 on failure.
>
> Additionally, this error path unconditionally frees the region struct.
> Since the region was already added to the global nommu_region_tree via
> add_nommu_region(), leaving it makes a potential dangling pointer in
> the tree and may cause a use-after-free on the next tree walk.
>
> This commit fixes those issues by updating return value as well as moving
> the region updates after the place that allocation is finished.
>
> The issue is discovered by Sashiko, linked below.
>
> Link: https://sashiko.dev/#/patchset/20260702012830.667205-1-thehajime%40gmail.com
> Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
hmm, there are still several issues on this function, reported with
new sashiko review.
https://sashiko.dev/#/patchset/c8513ee5aa8444ec9bf6c276043c9f833016a2fa.1783304131.git.thehajime%40gmail.com
I would try to find a way to do a similar review locally, and will be
back here once I don't see further pre-existing issues around this code.
-- Hajime
prev parent reply other threads:[~2026-07-06 2:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 2:18 [PATCH] mm: nommu: fix the error path when vma_iter_prealloc() fails Hajime Tazaki
2026-07-06 2:49 ` Hajime Tazaki [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=m2pl10u90p.wl-thehajime@gmail.com \
--to=thehajime@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=pfalcato@suse.de \
--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