linux/arch/sparc/mm
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
..
Makefile sparc32: introduce run-time patching of srmmu access functions 2012-05-27 23:52:49 -07:00
extable.c sparc: Add module.h to files previously implicitly using it. 2011-10-31 19:30:54 -04:00
fault_32.c vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
fault_64.c vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
gup.c sparc64: Implement __get_user_pages_fast(). 2014-10-30 09:38:28 -07:00
highmem.c sparc32: move kmap_init() to highmem.c 2012-07-26 16:46:17 -07:00
hugetlbpage.c hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-30 20:11:53 -07:00
hypersparc.S [PATCH] sparc32: vm_area_struct access for old Sun SPARCs. 2013-07-10 13:56:10 -07:00
init_32.c mm/SPARC: prepare for removing num_physpages and simplify mem_init() 2013-07-03 16:07:37 -07:00
init_64.c sparc64: Kill unnecessary tables and increase MAX_BANKS. 2014-10-30 09:38:28 -07:00
init_64.h sparc64: Use kernel page tables for vmemmap. 2014-10-30 09:38:27 -07:00
io-unit.c sparc32: Convert mmu_* interfaces from btfixup to method ops. 2012-05-13 13:57:05 -07:00
iommu.c sparc/iommu: fix typo s/265KB/256KB/ 2013-03-31 19:29:12 -04:00
leon_mm.c sparc32: srmmu_probe now knows about leon too 2012-05-27 23:52:51 -07:00
srmmu.c sparc32: destroy_context() and switch_mm() needs to disable interrupts. 2015-03-26 15:06:49 +01:00
srmmu.h sparc32,leon: move leon mmu functions to leon_mm.c 2012-05-19 23:27:38 -07:00
srmmu_access.S sparc32: introduce run-time patching of srmmu access functions 2012-05-27 23:52:49 -07:00
swift.S [PATCH] sparc32: vm_area_struct access for old Sun SPARCs. 2013-07-10 13:56:10 -07:00
tlb.c sparc64: Fix huge PMD invalidation. 2014-08-14 09:38:25 +08:00
tsb.c sparc64: Fix huge TSB mapping on pre-UltraSPARC-III cpus. 2014-08-14 09:38:26 +08:00
tsunami.S [PATCH] sparc32: vm_area_struct access for old Sun SPARCs. 2013-07-10 13:56:10 -07:00
ultra.S sparc64: Make PAGE_OFFSET variable. 2013-11-12 15:22:34 -08:00
viking.S [PATCH] sparc32: vm_area_struct access for old Sun SPARCs. 2013-07-10 13:56:10 -07:00