Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Oct 2020 18:47:30 +0300
From:      Nick Kostirya <nikolay.kostirya@i11.co>
To:        freebsd-stable@freebsd.org
Subject:   Re: mmap and MAP_STACK
Message-ID:  <20201021184730.080cecb3@i11.co>
In-Reply-To: <20201021152844.GK2643@kib.kiev.ua>
References:  <20201021165311.186bd606@i11.co> <20201021141657.GJ2643@kib.kiev.ua> <20201021181850.49126cdf@i11.co> <20201021152844.GK2643@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 21 Oct 2020 18:28:44 +0300
Konstantin Belousov <kostikbel@gmail.com> wrote:


> > 
> > kdump with MAP_STACK.
> > 
> >  87183 polyimport CALL  mmap(0,0x1000,0x3<PROT_READ|PROT_WRITE>,0x1402<MAP_PRIVATE|MAP_STACK|MAP_ANON>,0xffffffff,0,0)
> >  87183 polyimport RET   mmap -1 errno 22 Invalid argument  
> So it is anything but 'insufficient memory' (I suspected ENOMEM).
> EINVAL there is because sysctl security.bsd.stack_guard_page default value
> is 1, which means that at least one page of the stack is reserved as guard.
> Kernel does not allow to map stack that would have no data pages (all pages
> are guard).
> 
> Your mapping request is for one page, and one page is due to guard, so
> you get EINVAL.  Generally MAP_STACK is magic and requires caller to know
> what it does.

Thanks!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201021184730.080cecb3>