Skip to content

Commit bf018ee

Browse files
author
Vasily Gorbik
committed
s390/unwind: filter out unreliable bogus %r14
Currently unwinder unconditionally returns %r14 from the first frame pointed by %r15 from pt_regs. A task could be interrupted when a function already allocated this frame (if it needs it) for its callees or to store local variables. In that case this frame would contain random values from stack or values stored there by a callee. As we are only interested in %r14 to get potential return address, skip bogus return addresses which doesn't belong to kernel text. This helps to avoid duplicating filtering logic in unwider users, most of which use unwind_get_return_address() and would choke on bogus 0 address returned by it otherwise. Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 222ee90 commit bf018ee

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/s390/kernel/unwind_bc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ bool unwind_next_frame(struct unwind_state *state)
5757
ip = READ_ONCE_NOCHECK(sf->gprs[8]);
5858
reliable = false;
5959
regs = NULL;
60+
if (!__kernel_text_address(ip)) {
61+
/* skip bogus %r14 */
62+
state->regs = NULL;
63+
return unwind_next_frame(state);
64+
}
6065
} else {
6166
sf = (struct stack_frame *) state->sp;
6267
sp = READ_ONCE_NOCHECK(sf->back_chain);

0 commit comments

Comments
 (0)