mmap and MAP_STACK

Nick Kostirya nikolay.kostirya at i11.co
Wed Oct 21 15:47:34 UTC 2020


On Wed, 21 Oct 2020 18:28:44 +0300
Konstantin Belousov <kostikbel at 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!


More information about the freebsd-stable mailing list