From 0c33be7a1240bcb4b2418f6ef16e193496fc38ea Mon Sep 17 00:00:00 2001 From: Jerome Forissier Date: Fri, 31 Jul 2020 11:05:52 +0200 Subject: ldelf: arm: fix the unwind stack failure with __no_return function Similar fix to commit 19b3fe6c5a72 ("core: arm: fix the unwind stack failure with __no_return function") for user space. Signed-off-by: Jerome Forissier Reviewed-by: Jens Wiklander --- ldelf/unwind_arm32.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ldelf/unwind_arm32.c b/ldelf/unwind_arm32.c index 24c28976..0914466f 100644 --- a/ldelf/unwind_arm32.c +++ b/ldelf/unwind_arm32.c @@ -404,8 +404,13 @@ static bool unwind_stack_arm32(struct unwind_state_arm32 *state, /* The pc value is correct and will be overwritten, save it */ state->start_pc = state->registers[PC]; - /* Find the item to run */ - index = find_index(state->start_pc); + /* + * Find the item to run. Subtract 2 from PC to make sure that we're + * still inside the calling function in case a __no_return function + * (typically panic()) is called unconditionally and may cause LR and + * thus this PC to point into the next and entirely unrelated function. + */ + index = find_index(state->start_pc - 2); if (!index) return false; -- cgit v1.2.3