linux/arch
Vineet Gupta 73a0285856 ARC: signal handling robustify
commit e4140819da upstream.

A malicious signal handler / restorer can DOS the system by fudging the
user regs saved on stack, causing weird things such as sigreturn returning
to user mode PC but cpu state still being kernel mode....

Ensure that in sigreturn path status32 always has U bit; any other bogosity
(gargbage PC etc) will be taken care of by normal user mode exceptions mechanisms.

Reproducer signal handler:

    void handle_sig(int signo, siginfo_t *info, void *context)
    {
	ucontext_t *uc = context;
	struct user_regs_struct *regs = &(uc->uc_mcontext.regs);

	regs->scratch.status32 = 0;
    }

Before the fix, kernel would go off to weeds like below:

    --------->8-----------
    [ARCLinux]$ ./signal-test
    Path: /signal-test
    CPU: 0 PID: 61 Comm: signal-test Not tainted 4.0.0-rc5+ #65
    task: 8f177880 ti: 5ffe6000 task.ti: 8f15c000

    [ECR   ]: 0x00220200 => Invalid Write @ 0x00000010 by insn @ 0x00010698
    [EFA   ]: 0x00000010
    [BLINK ]: 0x2007c1ee
    [ERET  ]: 0x10698
    [STAT32]: 0x00000000 :                                   <--------
    BTA: 0x00010680	 SP: 0x5ffe7e48	 FP: 0x00000000
    LPS: 0x20003c6c	LPE: 0x20003c70	LPC: 0x00000000
    ...
    --------->8-----------

Reported-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2015-05-13 05:17:00 -07:00
..
alpha vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
arc ARC: signal handling robustify 2015-05-13 05:17:00 -07:00
arm ARM: dts: dove: Fix uart[23] reg property 2015-05-06 21:59:11 +02:00
arm64 arm64: vdso: fix build error when switching from LE to BE 2015-05-06 21:59:14 +02:00
avr32 vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
blackfin Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2014-01-31 09:31:14 -08:00
c6x C6x: time: Ensure consistency in __init 2015-05-06 21:59:21 +02:00
cris vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
frv vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
hexagon Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-01-25 11:17:34 -08:00
ia64 vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
m32r vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
m68k vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
metag vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
microblaze vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
mips nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:59:21 +02:00
mn10300 vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
openrisc vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
parisc vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
powerpc nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:59:21 +02:00
s390 nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:59:21 +02:00
score vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
sh nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:59:21 +02:00
sparc nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:59:21 +02:00
tile vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
um vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:31:55 +02:00
unicore32 nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:59:21 +02:00
x86 nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:59:21 +02:00
xtensa xtensa: ISS: fix locking in TAP network adapter 2015-05-06 21:59:18 +02:00
.gitignore arch: Ignore arch/i386 and arch/x86_64 2008-01-19 21:29:39 -08:00
Kconfig stackprotector: Introduce CONFIG_CC_STACKPROTECTOR_STRONG 2013-12-20 09:38:40 +01:00