linux/arch/um/kernel
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
..
skas um: Mark stub pages mapping with VM_PFNMAP 2013-07-19 10:45:17 +02:00
asm-offsets.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
config.c.in um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
dyn.lds.S UML: normalize global variables exported by vmlinux.lds 2013-07-03 16:07:34 -07:00
early_printk.c early_printk: consolidate random copies of identical code 2013-04-29 18:28:13 -07:00
exec.c um: get_safe_registers() should be done in flush_thread(), not start_thread() 2012-11-28 21:46:03 -05:00
exitcode.c uml: check length in exitcode_proc_write() 2013-10-30 12:24:49 -07:00
gmon_syms.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
gprof_syms.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
initrd.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
irq.c um: Add irq chip um/mask handlers 2013-09-07 10:57:19 +02:00
ksyms.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
maccess.c um: Implement probe_kernel_read() 2013-09-07 10:38:34 +02:00
Makefile um: Add support for CONFIG_STACKTRACE 2014-10-13 21:46:25 +02:00
mem.c um: handle pgtable_page_ctor() fail 2013-11-15 09:32:19 +09:00
physmem.c um: delete unnecessary bootmem struct page array 2014-10-13 17:15:09 +02:00
process.c asm/system.h: um: arch_align_stack() moved to asm/exec.h 2014-04-07 16:36:12 -07:00
ptrace.c ARCH: AUDIT: audit_syscall_entry() should not require the arch 2014-09-23 16:21:26 -04:00
reboot.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
sigio.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
signal.c um: Use get_signal() signal_setup_done() 2014-08-06 13:03:41 +02:00
smp.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
stacktrace.c um: Add support for CONFIG_STACKTRACE 2014-10-13 21:46:25 +02:00
syscall.c x86, um: switch to generic fork/vfork/clone 2012-11-28 22:13:44 -05:00
sysrq.c um: Add support for CONFIG_STACKTRACE 2014-10-13 21:46:25 +02:00
time.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
tlb.c um: Fix hung task in fix_range_common() 2014-07-20 13:16:20 +02:00
trap.c vm: add VM_FAULT_SIGSEGV handling support 2015-01-29 10:51:32 -08:00
um_arch.c um: delete unnecessary bootmem struct page array 2014-10-13 17:15:09 +02:00
umid.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
uml.lds.S UML: normalize global variables exported by vmlinux.lds 2013-07-03 16:07:34 -07:00
vmlinux.lds.S arm, cris, mips, sparc, powerpc, um, xtensa: fix build with bash 4.0 2009-09-20 12:28:22 +02:00