From 8e62954c9762a9939278f21d79fb83f658de9d7f Mon Sep 17 00:00:00 2001 From: wangxiao65 Date: Fri, 29 Nov 2024 06:43:47 +0000 Subject: [PATCH] arm64: fix SDEI stack frame unwind while UNW_4_14 is set --- ...tack-frame-unwind-while-UNW_4_14-is-.patch | 46 +++++++++++++++++++ crash.spec | 10 ++-- 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 0008-arm64-fix-SDEI-stack-frame-unwind-while-UNW_4_14-is-.patch diff --git a/0008-arm64-fix-SDEI-stack-frame-unwind-while-UNW_4_14-is-.patch b/0008-arm64-fix-SDEI-stack-frame-unwind-while-UNW_4_14-is-.patch new file mode 100644 index 0000000..ab02c02 --- /dev/null +++ b/0008-arm64-fix-SDEI-stack-frame-unwind-while-UNW_4_14-is-.patch @@ -0,0 +1,46 @@ +From 45685956da58b15d4542d59b95888b1968980c68 Mon Sep 17 00:00:00 2001 +From: Xiaoguang Wang +Date: Thu, 7 Nov 2024 14:40:07 +0800 +Subject: [PATCH] arm64: fix SDEI stack frame unwind while UNW_4_14 is set + +Fix two bugs: + 1) If BT_IRQSTACK is set, both irq_stack and sdei_normal_stack need + to be checked while switching to process stack. + 2) Use bt->frameptr in arm64_unwind_frame() just like irq stack. + +Fixes: 442da89f4898 ("crash: add SDEI stack resolution") +Signed-off-by: Xiaoguang Wang +--- + arm64.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/arm64.c b/arm64.c +index b99baa3..34c3b08 100644 +--- a/arm64.c ++++ b/arm64.c +@@ -3244,10 +3244,10 @@ arm64_unwind_frame(struct bt_info *bt, struct arm64_stackframe *frame) + + if (machdep->flags & UNW_4_14) { + if (((bt->flags & BT_IRQSTACK) && +- !arm64_on_irq_stack(bt->tc->processor, frame->fp)) || ++ !arm64_on_irq_stack(bt->tc->processor, frame->fp) && ++ !arm64_in_sdei_normal_stack(bt->tc->processor, frame->fp)) || + ((bt->flags & BT_OVERFLOW_STACK) && +- !arm64_on_overflow_stack(bt->tc->processor, frame->fp)) && +- !arm64_in_sdei_normal_stack(bt->tc->processor, frame->fp)) { ++ !arm64_on_overflow_stack(bt->tc->processor, frame->fp))) { + if (arm64_on_process_stack(bt, frame->fp)) { + arm64_set_process_stack(bt); + +@@ -3696,7 +3696,7 @@ arm64_back_trace_cmd(struct bt_info *bt) + arm64_set_overflow_stack(bt); + bt->flags |= BT_OVERFLOW_STACK; + } +- if (arm64_in_sdei_normal_stack(bt->tc->processor, bt->bptr)) { ++ if (arm64_in_sdei_normal_stack(bt->tc->processor, bt->frameptr)) { + arm64_set_sdei_normal_stack(bt); + bt->flags |= BT_IRQSTACK; + } +-- +2.34.1 + diff --git a/crash.spec b/crash.spec index 1a9830c..526505a 100644 --- a/crash.spec +++ b/crash.spec @@ -1,6 +1,6 @@ Name: crash Version: 8.0.2 -Release: 2 +Release: 3 Summary: Linux kernel crash utility. License: GPLv3 URL: https://crash-utility.github.io @@ -19,8 +19,9 @@ Patch5: 0004-riscv-support.patch %ifarch loongarch64 Patch6: 0005-crash-add-loongarch-support.patch %endif -Patch7: 0006-arm64-Fix-again-segfault-in-arm64_is_kernel_exceptio.patch -Patch8: 0007-arm64-fix-a-potential-segfault-when-unwind-frame.patch +Patch7: 0006-arm64-Fix-again-segfault-in-arm64_is_kernel_exceptio.patch +Patch8: 0007-arm64-fix-a-potential-segfault-when-unwind-frame.patch +Patch9: 0008-arm64-fix-SDEI-stack-frame-unwind-while-UNW_4_14-is-.patch BuildRequires: ncurses-devel zlib-devel lzo-devel snappy-devel texinfo libzstd-devel BuildRequires: gcc gcc-c++ bison m4 @@ -86,6 +87,9 @@ install -D -m 0644 defs.h %{buildroot}%{_includedir}/%{name}/defs.h %{_mandir}/man8/crash.8* %changelog +* Fri Nov 29 2024 wangxiao - 8.0.2-3 +- arm64: fix SDEI stack frame unwind while UNW_4_14 is set + * Tue Jul 25 2023 chenhaixiang - 8.0.2-2 - arm64: Fix again segfault in arm64_is_kernel_exception_frame() when corrupt stack pointer address is given -- Gitee