linux/arch/m68k
Linus Torvalds 1c2af9193e vm: add VM_FAULT_SIGSEGV handling support
commit 33692f2759 upstream.

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>
[shengyong: Backport to 3.14
 - adjust context
 - ignore modification for arch nios2, because 3.14 does not support it
 - add SIGSEGV handling to powerpc/cell spu_fault.c, because 3.14 does not
   separate it to copro_fault.c
 - add SIGSEGV handling to mm/memory.c, because 3.14 does not separate it
   to gup.c
]
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-29 10:31:55 +02:00
..
amiga m68k/amiga,atari: Fix specifying multiple debug= parameters 2013-12-08 11:03:21 +01:00
apollo m68k/UAPI: Use proper types (endianness/size) in <asm/bootinfo*.h> 2013-11-26 11:09:21 +01:00
atari m68k/irq - Use polled IRQ flag for MFP timer cascaded interrupts 2014-01-13 09:29:10 +01:00
bvme6000 m68k/UAPI: Use proper types (endianness/size) in <asm/bootinfo*.h> 2013-11-26 11:09:21 +01:00
configs m68k: Update defconfigs for v3.13-rc1 2013-12-30 21:29:05 +01:00
emu Merge branch 'for-3.14/core' of git://git.kernel.dk/linux-block 2014-01-30 11:19:05 -08:00
fpsp040 Fix common misspellings 2011-03-31 11:26:23 -03:00
hp300 m68k/UAPI: Use proper types (endianness/size) in <asm/bootinfo*.h> 2013-11-26 11:09:21 +01:00
ifpsp060 Fix common misspellings 2011-03-31 11:26:23 -03:00
include m68k: Wire up sched_setattr and sched_getattr 2014-02-10 20:10:20 +01:00
kernel m68k: Wire up sched_setattr and sched_getattr 2014-02-10 20:10:20 +01:00
lib m68k/uaccess: Fix asm constraints for userspace access 2013-06-24 19:44:19 +02:00
mac m68k: Remove superfluous inclusions of <asm/bootinfo.h> 2013-11-26 11:09:22 +01:00
math-emu m68k/math-emu: unsigned issue, 'unsigned long' will never be less than zero 2013-06-24 19:44:19 +02:00
mm vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
mvme16x m68k/UAPI: Use proper types (endianness/size) in <asm/bootinfo*.h> 2013-11-26 11:09:21 +01:00
mvme147 m68k/UAPI: Use proper types (endianness/size) in <asm/bootinfo*.h> 2013-11-26 11:09:21 +01:00
platform m68k: Simplify low level interrupt handling code 2013-11-13 20:21:46 +01:00
q40 m68k: Mark functions only called from setup_arch() __init 2013-11-26 11:08:54 +01:00
sun3 m68k/sun3: Dynamically allocate the table to track IOMMU use 2013-11-26 11:08:59 +01:00
sun3x m68k: Remove superfluous inclusions of <asm/bootinfo.h> 2013-11-26 11:09:22 +01:00
tools/amiga Convert files to UTF-8 and some cleanups 2007-10-19 23:21:04 +02:00
Kconfig m68k: Skip futex_atomic_cmpxchg_inatomic() test 2014-04-14 06:50:05 -07:00
Kconfig.bus m68k/atari: ROM port ISA adapter support 2013-04-16 21:08:11 +02:00
Kconfig.cpu Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu 2013-05-10 07:22:35 -07:00
Kconfig.debug m68k: remove CONFIG_EARLY_PRINTK dependency on CONFIG_EMBEDDED, default to n 2013-06-24 19:44:18 +02:00
Kconfig.devices m68k/atari: EtherNEC - add platform device support 2013-04-16 21:20:14 +02:00
Kconfig.machine m68k: remove 16 unused boards in Kconfig.machine 2013-08-26 16:51:14 +10:00
Makefile m68knommu: add support for the ColdFire 537x family of CPUs 2013-04-29 09:17:58 +10:00
install.sh kbuild: use INSTALLKERNEL to select customized installkernel script 2009-09-20 12:18:14 +02:00