From: Andrew Morton <akpm@linux-foundation.org>
To: Hajime Tazaki <thehajime@gmail.com>
Cc: liam@infradead.org, ljs@kernel.org, vbabka@kernel.org,
jannh@google.com, pfalcato@suse.de, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: nommu: add sysctl_max_map_count() check for do_mmap()
Date: Sun, 5 Jul 2026 15:10:17 -0700 [thread overview]
Message-ID: <20260705151017.289ed34630b503cdc1def407@linux-foundation.org> (raw)
In-Reply-To: <20260702012830.667205-1-thehajime@gmail.com>
On Thu, 2 Jul 2026 10:28:30 +0900 Hajime Tazaki <thehajime@gmail.com> wrote:
> The sysctl variable vm.max_map_count (sysctl_max_map_count) is not
> expose under !MMU case but used it wit the default vaule
> DEFAULT_MAX_MAP_COUNT as a limit of count.
This sounds like an oversight. I see no reason why nommu users cannot
alter max_map_count.
> This is currently used when
> a vma entry is split into two chunks (split_vma()) but not used when
> allocated (do_mmap()). As a result, even if users request a large
> number of allocate memory, it will keep allocating until OOM happens.
>
> This commit introduces a check at the begining of do_mmap in nommu.c to
> prevent this situation.
>
> ...
>
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -1035,6 +1035,9 @@ unsigned long do_mmap(struct file *file,
> if (ret < 0)
> return ret;
>
> + if (current->mm->map_count >= get_sysctl_max_map_count())
> + return -ENOMEM;
> +
> /* we ignore the address hint */
> addr = 0;
> len = PAGE_ALIGN(len);
Seems sensible, thanks. That's what the !NOMMU code does.
next parent reply other threads:[~2026-07-05 22:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260702012830.667205-1-thehajime@gmail.com>
2026-07-05 22:10 ` Andrew Morton [this message]
2026-07-05 22:15 ` [PATCH] mm: nommu: add sysctl_max_map_count() check for do_mmap() Andrew Morton
2026-07-06 0:19 ` Hajime Tazaki
2026-07-06 0:44 ` Andrew Morton
2026-07-06 2:03 ` Hajime Tazaki
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=20260705151017.289ed34630b503cdc1def407@linux-foundation.org \
--to=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=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