summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2024-04-29 15:28:45 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-06-12 12:39:24 +0300
commita0ce61a56f977b2398688dc28ff1b09a2344e6bb (patch)
tree99fbfa70261451972ed64e65f90dd05c0f7bfb87 /arch
parentdd69165ac3dc12d8550aeec3fc4439c084ded3d8 (diff)
downloadlinux-a0ce61a56f977b2398688dc28ff1b09a2344e6bb.tar.xz
s390/stacktrace: Skip first user stack frame
[ Upstream commit 87eceb17a987802aeee718be4decd19b56fc8e33 ] When walking user stack frames the first stack frame (where the stack pointer points to) should be skipped: the return address of the current function is saved in the previous stack frame, not the current stack frame, which is allocated for to be called functions. Fixes: aa44433ac4ee ("s390: add USER_STACKTRACE support") Reviewed-by: Jens Remus <jremus@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/s390/kernel/stacktrace.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
index e580d4cd2729..1c9e3b7739a2 100644
--- a/arch/s390/kernel/stacktrace.c
+++ b/arch/s390/kernel/stacktrace.c
@@ -95,6 +95,10 @@ void arch_stack_walk_user_common(stack_trace_consume_fn consume_entry, void *coo
while (1) {
if (__get_user(sp, &sf->back_chain))
break;
+ /* Sanity check: ABI requires SP to be 8 byte aligned. */
+ if (!sp || sp & 0x7)
+ break;
+ sf = (void __user *)sp;
if (__get_user(ip, &sf->gprs[8]))
break;
if (ip & 0x1) {
@@ -110,10 +114,6 @@ void arch_stack_walk_user_common(stack_trace_consume_fn consume_entry, void *coo
}
if (!store_ip(consume_entry, cookie, entry, perf, ip))
return;
- /* Sanity check: ABI requires SP to be aligned 8 bytes. */
- if (!sp || sp & 0x7)
- break;
- sf = (void __user *)sp;
first = false;
}
pagefault_enable();