s390/unwind: add stack pointer alignment sanity checks
authorMiroslav Benes <mbenes@suse.cz>
Wed, 27 Nov 2019 18:35:19 +0000 (19:35 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Sat, 30 Nov 2019 09:52:48 +0000 (10:52 +0100)
ABI requires SP to be aligned 8 bytes, report unwinding error otherwise.

Link: https://lkml.kernel.org/r/20191106095601.29986-5-mbenes@suse.cz
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Tested-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/dumpstack.c
arch/s390/kernel/unwind_bc.c

index d74e21a..d306fe0 100644 (file)
@@ -94,6 +94,10 @@ int get_stack_info(unsigned long sp, struct task_struct *task,
        if (!sp)
                goto unknown;
 
+       /* Sanity check: ABI requires SP to be aligned 8 bytes. */
+       if (sp & 0x7)
+               goto unknown;
+
        /* Check per-task stack */
        if (in_task_stack(sp, task, info))
                goto recursion_check;
index ef42d5f..da2d4d4 100644 (file)
@@ -92,6 +92,10 @@ bool unwind_next_frame(struct unwind_state *state)
                }
        }
 
+       /* Sanity check: ABI requires SP to be aligned 8 bytes. */
+       if (sp & 0x7)
+               goto out_err;
+
        ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, ip, (void *) sp);
 
        /* Update unwind state */