Re: [PATCH] [RFC] mm: mmap: Allow mmap(MAP_STACK) to map growable stack
From: Matthew Wilcox
Date: Thu Sep 12 2024 - 14:12:39 EST
On Wed, Sep 11, 2024 at 09:32:29PM -0400, Liam R. Howlett wrote:
> * Helge Deller <deller@xxxxxx> [240911 20:51]:
> > On 9/12/24 01:05, Liam R. Howlett wrote:
> > > If someone is using MAP_STACK to avoid having a huge page, they will
> > > also get a mapping that grows - which is different than what happens
> > > today.
> > >
> > > I'm not saying that's right, but someone could be abusing the existing
> > > flag and this will change the behaviour.
> >
> > Wouldn't a plain mmap() followed by madvise(MADV_NOHUGEPAGE) do exactly that?
> > Why abusing MAP_STACK for that?
>
> I can think of two answers:
> 1. An error that has worked without issues so far
> 2. One less system call
>
> I'm not saying this really is a blocker, but the change is not without
> risk as it does change behaviour the user could see.
>
> Interestingly enough, the man page is incorrect as it is written because
> the flag is not strictly a no-op; it ensures no huge pages. So the
> feature of applying VM_NOHUGEPAGE with the use of MAP_STACK is not
> documented today.
It's a recent change and I don't think it's something we necessarily
want to document. It was c4608d1bf7c6 which was December 2023.