powerpc/mm: Remove custom stack expansion checking
authorMichael Ellerman <mpe@ellerman.id.au>
Fri, 24 Jul 2020 09:25:27 +0000 (19:25 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 29 Jul 2020 11:02:12 +0000 (21:02 +1000)
commit773b3e53df5b84e73bf64998e4019f50a6662ad1
tree74bb696c046cf61521f3ef78d755583e614224d3
parent9ee571d84bf8cfdd587a1acbf3490ca90fc40c9d
powerpc/mm: Remove custom stack expansion checking

We have powerpc specific logic in our page fault handling to decide if
an access to an unmapped address below the stack pointer should expand
the stack VMA.

The logic aims to prevent userspace from doing bad accesses below the
stack pointer. However as long as the stack is < 1MB in size, we allow
all accesses without further checks. Adding some debug I see that I
can do a full kernel build and LTP run, and not a single process has
used more than 1MB of stack. So for the majority of processes the
logic never even fires.

We also recently found a nasty bug in this code which could cause
userspace programs to be killed during signal delivery. It went
unnoticed presumably because most processes use < 1MB of stack.

The generic mm code has also grown support for stack guard pages since
this code was originally written, so the most heinous case of the
stack expanding into other mappings is now handled for us.

Finally although some other arches have special logic in this path,
from what I can tell none of x86, arm64, arm and s390 impose any extra
checks other than those in expand_stack().

So drop our complicated logic and like other architectures just let
the stack expand as long as its within the rlimit.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Tested-by: Daniel Axtens <dja@axtens.net>
Link: https://lore.kernel.org/r/20200724092528.1578671-4-mpe@ellerman.id.au
arch/powerpc/mm/fault.c