diff --git a/backport-libdwfl-Fix-overflow-check-in-link_map.c-read_addrs.patch b/backport-libdwfl-Fix-overflow-check-in-link_map.c-read_addrs.patch new file mode 100644 index 0000000000000000000000000000000000000000..b64056b6bd1537ae252cb28e1d6d2a234edb1074 --- /dev/null +++ b/backport-libdwfl-Fix-overflow-check-in-link_map.c-read_addrs.patch @@ -0,0 +1,32 @@ +From 394cbe87c349b180a8b2aa4b0868698469d6de95 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Thu, 6 Jan 2022 16:44:56 +0100 +Subject: [PATCH] libdwfl: Fix overflow check in link_map.c read_addrs + +The buffer_available overflow check wasn't complete. Also check nb +isn't too big. + +https://sourceware.org/bugzilla/show_bug.cgi?id=28720 + +Signed-off-by: Mark Wielaard +--- + libdwfl/link_map.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c +index 0d8d1c1..e7c4173 100644 +--- a/libdwfl/link_map.c ++++ b/libdwfl/link_map.c +@@ -256,7 +256,8 @@ read_addrs (struct memory_closure *closure, + /* Read a new buffer if the old one doesn't cover these words. */ + if (buffer == NULL + || vaddr < *read_vaddr +- || vaddr - (*read_vaddr) + nb > *buffer_available) ++ || nb > *buffer_available ++ || vaddr - (*read_vaddr) > *buffer_available - nb) + { + release_buffer (closure, buffer, buffer_available, 0); + +-- +2.12.3 + diff --git a/backport-readelf-Handle-DW_LLE_GNU_view_pair.patch b/backport-readelf-Handle-DW_LLE_GNU_view_pair.patch new file mode 100644 index 0000000000000000000000000000000000000000..10958cc5f32cb170d99e54ea84e3ff7109c6b086 --- /dev/null +++ b/backport-readelf-Handle-DW_LLE_GNU_view_pair.patch @@ -0,0 +1,61 @@ +From 6044f53da763346a59a2c070e2dc9502b8b61459 Mon Sep 17 00:00:00 2001 +From: linzhuorong +Date: Wed, 30 Nov 2022 15:36:14 +0800 +Subject: [PATCH] readelf: Handle DW_LLE_GNU_view_pair + +Signed-off-by: linzhuorong +--- + libdw/dwarf.h | 6 +++++- + src/readelf.c | 12 ++++++++++++ + 2 files changed, 17 insertions(+), 1 deletion(-) + +diff --git a/libdw/dwarf.h b/libdw/dwarf.h +index 19a4be9..e70269c 100644 +--- a/libdw/dwarf.h ++++ b/libdw/dwarf.h +@@ -927,7 +927,11 @@ enum + DW_LLE_GNU_end_of_list_entry = 0x0, + DW_LLE_GNU_base_address_selection_entry = 0x1, + DW_LLE_GNU_start_end_entry = 0x2, +- DW_LLE_GNU_start_length_entry = 0x3 ++ DW_LLE_GNU_start_length_entry = 0x3, ++ ++ // http://www.fsfla.org/~lxoliva/papers/sfn/dwarf6-sfn-lvu.txt ++ // https://dwarfstd.org/ShowIssue.php?issue=170427.1 ++ DW_LLE_GNU_view_pair = 0x9 + }; + + +diff --git a/src/readelf.c b/src/readelf.c +index 9b47262..c19b0a5 100644 +--- a/src/readelf.c ++++ b/src/readelf.c +@@ -4120,6 +4120,8 @@ dwarf_loc_list_encoding_string (unsigned int kind) + #define DWARF_ONE_KNOWN_DW_LLE(NAME, CODE) case CODE: return #NAME; + DWARF_ALL_KNOWN_DW_LLE + #undef DWARF_ONE_KNOWN_DW_LLE ++ /* DW_LLE_GNU_view_pair is special/incompatible with default codes. */ ++ case DW_LLE_GNU_view_pair: return "GNU_view_pair"; + default: + return NULL; + } +@@ -9514,6 +9516,16 @@ print_debug_loclists_section (Dwfl_Module *dwflmod, + readp += len; + break; + ++ case DW_LLE_GNU_view_pair: ++ if ((uint64_t) (nexthdr - readp) < 1) ++ goto invalid_entry; ++ get_uleb128 (op1, readp, nexthdr); ++ if ((uint64_t) (nexthdr - readp) < 1) ++ goto invalid_entry; ++ get_uleb128 (op2, readp, nexthdr); ++ printf (" %" PRIx64 ", %" PRIx64 "\n", op1, op2); ++ break; ++ + default: + goto invalid_entry; + } +-- +2.12.3 + diff --git a/elfutils.spec b/elfutils.spec index 26419f15d13205f9bdfdb18abb2c8409b78dd7e7..ebae16a7982f6b1f753348e4a18639b7ea2f7e30 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,7 +1,7 @@ # -*- rpm-spec from http://elfutils.org/ -*- Name: elfutils Version: 0.185 -Release: 15 +Release: 17 Summary: A collection of utilities and DSOs to handle ELF files and DWARF data URL: http://elfutils.org/ License: GPLv3+ and (GPLv2+ or LGPLv3+) @@ -12,7 +12,9 @@ Patch1: Fix-segfault-in-eu-ar-m.patch Patch2: Fix-error-of-parsing-object-file-perms.patch Patch3: Fix-issue-of-moving-files-by-ar-or-br.patch Patch4: Get-instance-correctly-for-eu-ar-N-option.patch -Patch5: elfutils-Add-sw64-architecture.patch +Patch5: backport-readelf-Handle-DW_LLE_GNU_view_pair.patch +Patch6: elfutils-Add-sw64-architecture.patch +Patch7: backport-libdwfl-Fix-overflow-check-in-link_map.c-read_addrs.patch Provides: elfutils-libelf elfutils-default-yama-scope default-yama-scope elfutils-libs Obsoletes: elfutils-libelf < %{version}-%{release} elfutils-default-yama-scope < %{version}-%{release} elfutils-libs < %{version}-%{release} @@ -263,9 +265,21 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog -* Wed Oct 19 2022 wuzx - 0.185-15 +* Mon Dec 5 2022 linzhuorong - 0.185-17 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:libdwfl: Fix overflow check in link_map.c read_addrs + +* Wed Oct 19 2022 wuzx - 0.185-16 - add sw64 patch +* Wed Nov 30 2022 linzhuorong - 0.185-15 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:readelf: Handle DW_LLE_GNU_view_pair + * Fri Sep 30 2022 hubin - 0.185-14 - Type:bugfix - ID:NA