From 8faef51dff53ce83b16e4530073693267bd5099e Mon Sep 17 00:00:00 2001 From: linzhuorong Date: Mon, 5 Dec 2022 03:48:01 +0000 Subject: [PATCH 1/3] [Backport] readelf: Handle DW_LLE_GNU_view_pair Signed-off-by: linzhuorong --- ...-readelf-Handle-DW_LLE_GNU_view_pair.patch | 61 +++++++++++++++++++ elfutils.spec | 11 +++- 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 backport-readelf-Handle-DW_LLE_GNU_view_pair.patch 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 0000000..10958cc --- /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 26419f1..0f4c12d 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: 16 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,8 @@ 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 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} @@ -266,6 +267,12 @@ exit 0 * Wed Oct 19 2022 wuzx - 0.185-15 - 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 -- Gitee From 0cf827dd492f21817f7ea17f20219867f95f2587 Mon Sep 17 00:00:00 2001 From: linzhuorong Date: Mon, 5 Dec 2022 06:30:19 +0000 Subject: [PATCH 2/3] [BackPort] libdwfl: Fix overflow check in link_map.c read_addrs Signed-off-by: linzhuorong --- ...rflow-check-in-link_map.c-read_addrs.patch | 32 +++++++++++++++++++ elfutils.spec | 11 +++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 backport-libdwfl-Fix-overflow-check-in-link_map.c-read_addrs.patch 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 0000000..b64056b --- /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/elfutils.spec b/elfutils.spec index 0f4c12d..ebae16a 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,7 +1,7 @@ # -*- rpm-spec from http://elfutils.org/ -*- Name: elfutils Version: 0.185 -Release: 16 +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+) @@ -14,6 +14,7 @@ Patch3: Fix-issue-of-moving-files-by-ar-or-br.patch Patch4: Get-instance-correctly-for-eu-ar-N-option.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} @@ -264,7 +265,13 @@ 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 -- Gitee From 10cc3f6920c7b7aa47af4727a54ffbbbf868e8c9 Mon Sep 17 00:00:00 2001 From: linzhuorong Date: Mon, 5 Dec 2022 07:12:22 +0000 Subject: [PATCH 3/3] fix spec %prep Signed-off-by: linzhuorong --- elfutils.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elfutils.spec b/elfutils.spec index ebae16a..6671ea8 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -128,9 +128,11 @@ such servers to download those files on demand. %patch2 -p1 %patch3 -p1 %patch4 -p1 -%ifarch sw_64 %patch5 -p1 +%ifarch sw_64 +%patch6 -p1 %endif +%patch7 -p1 %build %configure --program-prefix=%{_programprefix} -- Gitee