linux/arch/arc/kernel
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
..
.gitignore ARC: Add some .gitignore entries 2013-08-26 09:40:24 +05:30
Makefile ARC: Add perf support for ARC700 cores 2013-11-12 09:45:38 +05:30
arc_hostlink.c ARC: Hostlink Pseudo-Driver for Metaware Debugger 2013-02-15 23:16:10 +05:30
arcksyms.c ARC: Build system: Makefiles, Kconfig, Linker script 2013-02-11 20:00:25 +05:30
asm-offsets.c ARC: pt_regs update #5: Use real ECR for pt_regs->event vs. synth values 2013-06-26 14:04:48 +05:30
clk.c ARC: fix typo with clock speed 2013-05-07 13:43:54 +05:30
ctx_sw.c ARC: [SMP] Fix build failures for large NR_CPUS 2013-11-06 10:41:46 +05:30
ctx_sw_asm.S ARC: Fix build breakage for !CONFIG_ARC_DW2_UNWIND 2015-01-29 17:40:50 -08:00
devtree.c arc: remove unnecessary prom.h includes 2013-10-09 20:04:01 -05:00
disasm.c ARC port updates for Linux 3.10 (part 1) 2013-05-09 14:36:27 -07:00
entry.S ARC: switch to generic ENTRY/END assembler annotations 2015-01-27 08:18:54 -08:00
fpu.c ARC: Process-creation/scheduling/idle-loop 2013-02-11 20:00:38 +05:30
head.S ARC: Disable caches in early boot if so configured 2014-11-14 08:59:56 -08:00
irq.c arc: remove '__init' for get_hw_config_num_irq() 2013-11-06 10:41:43 +05:30
kgdb.c arc: kgdb: add default implementation for kgdb_roundup_cpus() 2013-11-06 10:41:41 +05:30
kprobes.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2013-11-15 16:47:22 -08:00
module.c ARC: Fix coding style issues 2013-04-09 12:21:14 +05:30
perf_event.c ARC: [perf] Fix a few thinkos 2013-11-28 15:49:59 +05:30
process.c ARC: pt_regs update #5: Use real ECR for pt_regs->event vs. synth values 2013-06-26 14:04:48 +05:30
ptrace.c ARC: Implement ptrace(PTRACE_GET_THREAD_AREA) 2014-07-28 08:06:04 -07:00
reset.c arc: export symbol for pm_power_off in reset.c 2013-11-06 10:41:44 +05:30
setup.c ARC: [cmdline] support External Device Trees from u-boot 2014-01-16 18:53:16 +05:30
signal.c ARC: signal handling robustify 2015-05-13 05:17:00 -07:00
smp.c ARC: [SMP] optimize IPI send and receive 2013-12-23 12:05:04 +05:30
stacktrace.c ARC: Fix KSTK_ESP() 2015-03-18 13:31:31 +01:00
sys.c ARC: ABIv3: fork/vfork wrappers not needed in "no-legacy-syscall" ABI 2013-03-11 19:01:10 +05:30
time.c ARC: [SMP] Disallow RTSC 2013-11-07 14:34:31 +05:30
traps.c ARC: Reduce #ifdef'ery for unaligned access emulation 2013-11-06 10:41:39 +05:30
troubleshoot.c ARC changes for 3.11 2013-07-03 11:09:27 -07:00
unaligned.c ARC: Handle zero-overhead-loop in unaligned access handler 2013-09-27 16:28:23 +05:30
unwind.c ARC: warn on improper stack unwind FDE entries 2013-06-27 14:37:59 +05:30
vmlinux.lds.S ARC: Adjustments for gcc 4.8 2013-06-27 14:35:32 +05:30