]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
mm: enlarge stack guard gap
authorMichal Hocko <mhocko@suse.com>
Fri, 12 May 2017 07:09:30 +0000 (09:09 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 8 Jun 2017 09:59:24 +0000 (11:59 +0200)
commitfe388e5751e74b3534ee21d01b999795dfc83d39
treeab5d8890730f2de6c2c3a5d29539c23b99361ff2
parent7e0f6af1aaf206d4989c37c34c055d522a45ab2c
mm: enlarge stack guard gap

Stack guard page is a useful feature to reduce a risk of stack smashing
into a different mapping. We have been using a single page gap which
is sufficient to prevent having stack adjacent to a different mapping.
But this seems to be insufficient in the light of the stack usage in
the userspace. E.g. glibc uses as large as 64kB alloca() in many
commonly used functions. This will become especially dangerous for suid
binaries and the default no limit for the stack size limit because those
applications can be tricked to consume a large portion of the stack and
a single glibc call could jump over the guard page. These attacks are
not theoretical, unfortunatelly.

Make those attacks less probable by increasing the stack guard gap
to 1MB (on systems with 4k pages but make it depend on the page size
because systems with larger base pages might cap stack allocations in
the PAGE_SIZE units) which should cover larger alloca() and VLA stack
allocations. It is obviously not a full fix because the problem is
somehow inherent but it should reduce attack space a lot. One could
argue that the gap size should be configurable from the userspace but
that can be done later on top when somebody finds that the new 1MB is
not suitable or even wrong for some special case applications.

Implementation wise, get rid of check_stack_guard_page and move all the
guard page specific code to expandable_stack_area which always tries to
guarantee the gap. do_anonymous_page then just calls expand_stack. Also
get rid of stack_guard_page_{start,end} and replace them with
stack_guard_area to handle stack population and /proc/<pid>/[s]maps.

This should clean up the code which is quite scattered currently
and therefore justify the change.

TODO: ia64 page fault handling calls expand_upwards explicitly for
register store. Do we need a gap there as well?

CVE-2017-1000364

Signed-off-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/ia64/mm/fault.c
fs/exec.c
fs/proc/task_mmu.c
include/linux/mm.h
mm/gup.c
mm/memory.c
mm/mmap.c