kernel-fxtec-pro1x/arch/openrisc/kernel
Stafford Horne ff62a41403 openrisc: Fix oops caused when dumping stack
[ Upstream commit 57b8e277c33620e115633cdf700a260b55095460 ]

When dumping a stack with 'cat /proc/#/stack' the kernel would oops.
For example:

    # cat /proc/690/stack
    Unable to handle kernel access
     at virtual address 0x7fc60f58

    Oops#: 0000
    CPU #: 0
       PC: c00097fc    SR: 0000807f    SP: d6f09b9c
    GPR00: 00000000 GPR01: d6f09b9c GPR02: d6f09bb8 GPR03: d6f09bc4
    GPR04: 7fc60f5c GPR05: c00099b4 GPR06: 00000000 GPR07: d6f09ba3
    GPR08: ffffff00 GPR09: c0009804 GPR10: d6f08000 GPR11: 00000000
    GPR12: ffffe000 GPR13: dbb86000 GPR14: 00000001 GPR15: dbb86250
    GPR16: 7fc60f63 GPR17: 00000f5c GPR18: d6f09bc4 GPR19: 00000000
    GPR20: c00099b4 GPR21: ffffffc0 GPR22: 00000000 GPR23: 00000000
    GPR24: 00000001 GPR25: 000002c6 GPR26: d78b6850 GPR27: 00000001
    GPR28: 00000000 GPR29: dbb86000 GPR30: ffffffff GPR31: dbb862fc
      RES: 00000000 oGPR11: ffffffff
    Process cat (pid: 702, stackpage=d79d6000)

    Stack:
    Call trace:
    [<598977f2>] save_stack_trace_tsk+0x40/0x74
    [<95063f0e>] stack_trace_save_tsk+0x44/0x58
    [<b557bfdd>] proc_pid_stack+0xd0/0x13c
    [<a2df8eda>] proc_single_show+0x6c/0xf0
    [<e5a737b7>] seq_read+0x1b4/0x688
    [<2d6c7480>] do_iter_read+0x208/0x248
    [<2182a2fb>] vfs_readv+0x64/0x90

This was caused by the stack trace code in save_stack_trace_tsk using
the wrong stack pointer.  It was using the user stack pointer instead of
the kernel stack pointer.  Fix this by using the right stack.

Also for good measure we add try_get_task_stack/put_task_stack to ensure
the task is not lost while we are walking it's stack.

Fixes: eecac38b04 ("openrisc: support framepointers and STACKTRACE_SUPPORT")
Signed-off-by: Stafford Horne <shorne@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-08-21 11:05:37 +02:00
..
.gitignore
asm-offsets.c
dma.c openrisc: use generic dma_noncoherent_ops 2018-07-21 13:49:48 +09:00
entry.S openrisc: Fix issue with argument clobbering for clone/fork 2020-06-25 15:33:01 +02:00
head.S openrisc: Fix broken paths to arch/or32 2019-12-05 09:20:40 +01:00
irq.c openrisc: Use the new GENERIC_IRQ_MULTI_HANDLER 2018-08-03 12:14:09 +02:00
Makefile OpenRISC updates for v4.15 2017-11-13 12:12:00 -08:00
module.c
or32_ksyms.c
process.c
prom.c
ptrace.c
setup.c openrisc: initial SMP support 2017-11-03 14:01:13 +09:00
signal.c
smp.c openrisc: fix possible deadlock scenario during timer sync 2017-11-03 14:01:17 +09:00
stacktrace.c openrisc: Fix oops caused when dumping stack 2020-08-21 11:05:37 +02:00
sync-timer.c openrisc: add tick timer multi-core sync logic 2017-11-03 14:01:16 +09:00
sys_call_table.c
time.c openrisc: add tick timer multi-core sync logic 2017-11-03 14:01:16 +09:00
traps.c openrisc: entry: Fix delay slot exception detection 2018-07-01 16:48:24 +09:00
unwinder.c openrisc: support framepointers and STACKTRACE_SUPPORT 2017-11-03 14:01:15 +09:00
vmlinux.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vmlinux.lds.S openrisc: Make THREAD_SIZE available to vmlinux.lds 2018-01-09 23:21:02 +00:00