diff --git a/backport-aarch64-unw_step-validates-address-before-calling-dwarf_get.patch b/backport-aarch64-unw_step-validates-address-before-calling-dwarf_get.patch new file mode 100644 index 0000000000000000000000000000000000000000..7be6a50be562faee61324d6b791f7c26ed0e9381 --- /dev/null +++ b/backport-aarch64-unw_step-validates-address-before-calling-dwarf_get.patch @@ -0,0 +1,48 @@ +From 8a0e2fa6579085dc8f51b2bdd90d8b00a2e7d6ab Mon Sep 17 00:00:00 2001 +From: he7850 +Date: Wed, 3 May 2023 15:18:27 +0800 +Subject: [PATCH] aarch64: unw_step() validates address before calling + dwarf_get + +Signed-off-by: he7850 +--- + src/aarch64/Gstep.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/src/aarch64/Gstep.c b/src/aarch64/Gstep.c +index f4ef369d3..a2ed9bc35 100644 +--- a/src/aarch64/Gstep.c ++++ b/src/aarch64/Gstep.c +@@ -156,18 +156,28 @@ unw_step (unw_cursor_t *cursor) + dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_X30], &c->dwarf.ip); + } + +- /* Restore default memory validation state */ +- c->validate = validate; +- + ret = dwarf_step (&c->dwarf); + Debug(1, "dwarf_step()=%d\n", ret); + ++ /* Restore default memory validation state */ ++ c->validate = validate; ++ + if (unlikely (ret == -UNW_ESTOPUNWIND)) + return ret; + + if (unlikely (ret < 0)) + { + /* DWARF failed. */ ++ ++ /* ++ * We could get here because of missing/bad unwind information. ++ * Validate all addresses before dereferencing. ++ */ ++ if (c->dwarf.as == unw_local_addr_space) ++ { ++ c->validate = 1; ++ } ++ + if (is_plt_entry (&c->dwarf)) + { + Debug (2, "found plt entry\n"); + diff --git a/libunwind.spec b/libunwind.spec index 1c41200e19d02301499b73f65ffcaeed26c65344..296f0e71db5433640c91f3ab5ec3f0e37fcb9946 100644 --- a/libunwind.spec +++ b/libunwind.spec @@ -1,7 +1,7 @@ Name: libunwind Epoch: 2 Version: 1.3.1 -Release: 5 +Release: 6 Summary: Libunwind provides a C ABI to determine the call-chain of a program License: BSD URL: http://savannah.nongnu.org/projects/libunwind @@ -19,6 +19,7 @@ Patch6008: dwarf-Push-correct-CFA-onto-stack-for-dwarf-expressi.patch Patch6009: backport-check-namespace.sh-adjust-aarch64-symbols.patch Patch6010: backport-Ltest-mem-validate-Disable-inlining-for-consume_and_.patch Patch6011: backport-tests-run-coredump-unwind-Skip-test-if-no-coredump-h.patch +Patch6012: backport-aarch64-unw_step-validates-address-before-calling-dwarf_get.patch ExclusiveArch: aarch64 %{ix86} x86_64 @@ -96,6 +97,12 @@ make check || true %{_mandir}/*/* %changelog +* Mon Jul 03 2023 chenziyang - 2:1.3.1-6 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:backport upstream patches to fix failed Ltest-mem-validate testcase + * Tue Feb 21 2021 shixuantong - 2:1.3.1-5 - fix some test fail