linux/arch/s390/mm
Linus Torvalds 33692f2759 vm: add VM_FAULT_SIGSEGV handling support
The core VM already knows about VM_FAULT_SIGBUS, but cannot return a
"you should SIGSEGV" error, because the SIGSEGV case was generally
handled by the caller - usually the architecture fault handler.

That results in lots of duplication - all the architecture fault
handlers end up doing very similar "look up vma, check permissions, do
retries etc" - but it generally works.  However, there are cases where
the VM actually wants to SIGSEGV, and applications _expect_ SIGSEGV.

In particular, when accessing the stack guard page, libsigsegv expects a
SIGSEGV.  And it usually got one, because the stack growth is handled by
that duplicated architecture fault handler.

However, when the generic VM layer started propagating the error return
from the stack expansion in commit fee7e49d45 ("mm: propagate error
from stack expansion even for guard page"), that now exposed the
existing VM_FAULT_SIGBUS result to user space.  And user space really
expected SIGSEGV, not SIGBUS.

To fix that case, we need to add a VM_FAULT_SIGSEGV, and teach all those
duplicate architecture fault handlers about it.  They all already have
the code to handle SIGSEGV, so it's about just tying that new return
value to the existing code, but it's all a bit annoying.

This is the mindless minimal patch to do this.  A more extensive patch
would be to try to gather up the mostly shared fault handling logic into
one generic helper routine, and long-term we really should do that
cleanup.

Just from this patch, you can generally see that most architectures just
copied (directly or indirectly) the old x86 way of doing things, but in
the meantime that original x86 model has been improved to hold the VM
semaphore for shorter times etc and to handle VM_FAULT_RETRY and other
"newer" things, so it would be a good idea to bring all those
improvements to the generic case and teach other architectures about
them too.

Reported-and-tested-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Jan Engelhardt <jengelh@inai.de>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> # "s390 still compiles and boots"
Cc: linux-arch@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-01-29 10:51:32 -08:00
..
cmm.c s390: convert use of typedef ctl_table to struct ctl_table 2013-10-28 08:36:25 +01:00
dump_pagetables.c s390/mm: remove change bit override support 2014-09-25 10:52:09 +02:00
extable.c s390/exceptions: switch to relative exception table entries 2012-09-26 15:45:10 +02:00
extmem.c s390/comments: unify copyright messages and remove file names 2012-07-20 11:15:04 +02:00
fault.c vm: add VM_FAULT_SIGSEGV handling support 2015-01-29 10:51:32 -08:00
gup.c s390/gup: handle zero nr_pages case correctly 2013-10-24 17:17:01 +02:00
hugetlbpage.c s390/mm: remove change bit override support 2014-09-25 10:52:09 +02:00
init.c mm: export symbol dependencies of is_zero_pfn() 2014-09-14 16:25:14 +02:00
maccess.c /dev/mem: Use more consistent data types 2014-11-10 15:59:21 +01:00
Makefile s390/mem_detect: move memory detection code to mm folder 2013-05-02 15:50:22 +02:00
mem_detect.c s390/mm: Convert bootmem to memblock 2014-05-20 08:58:40 +02:00
mmap.c s390/mmap: randomize mmap base for bottom up direction 2013-11-13 12:09:08 +09:00
page-states.c s390/cmma: remove "cmma disable" code in case of dump again 2014-05-20 08:58:42 +02:00
pageattr.c mm/debug-pagealloc: make debug-pagealloc boottime configurable 2014-12-13 12:42:48 -08:00
pgtable.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2015-01-15 10:50:29 +13:00
vmem.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2014-10-14 03:47:00 +02:00