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 a981dde82095139ce555143cc624498d3db7bba6..f6168fae2f7ff6d4bce6799000bdec10e1636e13 100644 --- a/libunwind.spec +++ b/libunwind.spec @@ -1,7 +1,7 @@ Name: libunwind Epoch: 2 Version: 1.6.2 -Release: 4 +Release: 5 Summary: Libunwind provides a C ABI to determine the call-chain of a program License: BSD URL: http://savannah.nongnu.org/projects/libunwind @@ -10,6 +10,7 @@ Source: http://download-mirror.savannah.gnu.org/releases/libunwind/libunwind-%{v Patch0001: 0001-fix-byte_order_is_valid-function-logic.patch Patch2: backport-check-namespace.sh-adjust-aarch64-symbols.patch Patch3: backport-tests-run-coredump-unwind-Skip-test-if-no-coredump-h.patch +Patch4: backport-aarch64-unw_step-validates-address-before-calling-dwarf_get.patch ExclusiveArch: aarch64 %{ix86} x86_64 @@ -87,6 +88,12 @@ make check || true %{_mandir}/*/* %changelog +* Tue Jun 20 2023 wangjiang - 2:1.6.2-5 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix failed testcase + * Mon Feb 20 2023 shixuantong - 2:1.6.2-4 - Type:bugfix - ID:NA