linux/arch/metag
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
..
boot metag: tz1090: instantiate gpio-tz1090-pdc 2013-07-22 10:55:31 +01:00
configs metag: minimal TZ1090 (Comet) SoC infrastructure 2013-06-13 12:14:07 +01:00
include metag: Fix KSTK_EIP() and KSTK_ESP() macros 2015-03-06 14:43:31 -08:00
kernel metag/smp: Make boot_secondary() static 2014-01-06 09:59:22 +00:00
lib metag: move EXPORT_SYMBOL(csum_partial) to metag_ksyms.c 2013-07-04 10:00:02 +01:00
mm vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
oprofile metag: OProfile support 2013-03-15 13:21:05 +00:00
tbx metag: handle low level kicks directly 2013-11-06 10:40:02 +00:00
Kconfig kernel: remove CONFIG_USE_GENERIC_SMP_HELPERS 2013-11-15 09:32:22 +09:00
Kconfig.debug consolidate per-arch stack overflow debugging options 2013-07-04 11:25:39 -07:00
Kconfig.soc metag: tz1090: select and instantiate gpio-tz1090 2013-07-22 10:55:31 +01:00
Makefile metag: minimal TZ1090 (Comet) SoC infrastructure 2013-06-13 12:14:07 +01:00