linux/arch/arc
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>
2015-05-13 05:17:00 -07:00
..
boot ARC: [nsimosci] move peripherals to match model to FPGA 2015-01-27 08:18:54 -08:00
configs ARC: [nsimosci] Unbork console 2014-04-14 06:50:05 -07:00
include ARC: Fix KSTK_ESP() 2015-03-18 13:31:31 +01:00
kernel ARC: signal handling robustify 2015-05-13 05:17:00 -07:00
lib ARC: switch to generic ENTRY/END assembler annotations 2015-01-27 08:18:54 -08:00
mm arc: mm: Fix build failure 2015-04-29 10:31:57 +02:00
oprofile ARC: OProfile support 2013-02-15 23:16:00 +05:30
plat-arcfpga ARC: Remove ARC_HAS_COH_RTSC 2014-05-13 13:32:49 +02:00
plat-tb10x ARC: [TB10x] Updates for GPIO and pinctrl 2013-11-11 09:57:44 +05:30
Kbuild ARC: Build system: Makefiles, Kconfig, Linker script 2013-02-11 20:00:25 +05:30
Kconfig ARC changes for 3.14 2014-01-25 10:50:43 -08:00
Kconfig.debug consolidate per-arch stack overflow debugging options 2013-07-04 11:25:39 -07:00
Makefile ARC: Adjustments for gcc 4.8 2013-06-27 14:35:32 +05:30