Re: [lkp-robot] [mm] 1be7107fbe: kernel_BUG_at_mm/mmap.c

From: Oleg Nesterov
Date: Wed Jun 21 2017 - 16:27:59 EST


On 06/21, Linus Torvalds wrote:
>
> On Wed, Jun 21, 2017 at 12:33 PM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> > - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
> > +if (0) if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
>
> This smells bad.

Yes.

> That test is not about grow-down or even the guard page. That test is
> that it's always wrong to grow down the stack below %esp.

Sure.

but let me repeat that this test was essentially dismissed when the stack
guard page was introduced. Simply because do_page_pault() never hits (before
the recent patch) this need-to-grow-VM_GROWSDOWN-vma path if the stack grows
by less than PAGE_SIZE.

IOP. Suppose that an application does

char * p = mmap(MAP_GROWSDOWN);
for (;;)
*p-- = 'x';


before the "larger stack guard gap, between vmas" change the stack was
enlarged by do_anonymous_page(), __do_page_fault() didn't hit this path.

Now __do_page_fault() tries to expand the stack itself, and this check
fails.

Oleg.