From 53461eaf5bce68cf8fa178a0eeee94b9f1af1b0a Mon Sep 17 00:00:00 2001 From: h30032433 Date: Fri, 28 Feb 2025 15:01:35 +0800 Subject: [PATCH] back port PR29171 to fix invalid read causing SIGSEGV fix issue: https://sourceware.org/bugzilla/show_bug.cgi?id=29171 --- ...PR29171-invalid-read-causing-SIGSEGV.patch | 58 +++++++++++++++++++ binutils.spec | 6 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 backport-PR29171-invalid-read-causing-SIGSEGV.patch diff --git a/backport-PR29171-invalid-read-causing-SIGSEGV.patch b/backport-PR29171-invalid-read-causing-SIGSEGV.patch new file mode 100644 index 0000000..2957334 --- /dev/null +++ b/backport-PR29171-invalid-read-causing-SIGSEGV.patch @@ -0,0 +1,58 @@ +From be38442ddacf1fd25c8868d0491ea9e98b0e9ca7 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Tue, 24 May 2022 10:47:35 +0930 +Subject: [PATCH] PR29171, invalid read causing SIGSEGV + +The fix here is to pass "section" down to read_and_display_attr_value. +The test in read_and_display_attr_value is a little bit of hardening. + + PR 29171 + * dwarf.c (display_debug_macro, display_debug_names): Pass section + to read_and_display_attr_value2. + (read_and_display_attr_value): Don't attempt to check for .dwo + section name when section is NULL. + +Reference:https://github.com/bminor/binutils-gdb/commit/be38442ddacf1fd25c8868d0491ea9e98b0e9ca7 +Conflict:NA + +--- + binutils/dwarf.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/binutils/dwarf.c b/binutils/dwarf.c +index d820c2152..a0dfd4df4 100644 +--- a/binutils/dwarf.c ++++ b/binutils/dwarf.c +@@ -2717,7 +2717,7 @@ read_and_display_attr_value (unsigned long attribute, + case DW_FORM_strx4: + if (!do_loc) + { +- const char *suffix = strrchr (section->name, '.'); ++ const char *suffix = section ? strrchr (section->name, '.') : NULL; + bool dwo = suffix && strcmp (suffix, ".dwo") == 0; + + if (do_wide) +@@ -6273,8 +6273,9 @@ display_debug_macro (struct dwarf_section *section, + SAFE_BYTE_GET_AND_INC (val, desc, 1, end); + curr + = read_and_display_attr_value (0, val, 0, +- start, curr, end, 0, 0, offset_size, +- version, NULL, 0, NULL, ++ start, curr, end, 0, 0, ++ offset_size, version, ++ NULL, 0, section, + NULL, ' ', -1); + if (n != nargs - 1) + printf (","); +@@ -10310,7 +10311,7 @@ display_debug_names (struct dwarf_section *section, void *file) + unit_start, entryptr, unit_end, + 0, 0, offset_size, + dwarf_version, NULL, +- (tagno < 0), NULL, ++ (tagno < 0), section, + NULL, '=', -1); + } + ++tagno; +-- +2.43.0 + diff --git a/binutils.spec b/binutils.spec index c8a1065..ccea3cd 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,7 +1,7 @@ Summary: Binary utilities Name: binutils Version: 2.37 -Release: 26 +Release: 27 License: GPLv3+ URL: https://sourceware.org/binutils @@ -82,6 +82,7 @@ Patch56: backport-CVE-2022-48064.patch Patch57: backport-CVE-2022-4285.patch Patch58: backport-CVE-2022-38533.patch Patch59: backport-libctf-fix-ref-leak-of-names-of-newly-inserted-non-r.patch +Patch60: backport-PR29171-invalid-read-causing-SIGSEGV.patch %ifarch loongarch64 # LoongArch-related patches start with Patch101 @@ -428,6 +429,9 @@ fi %{_infodir}/bfd*info* %changelog +* Fri Feb 28 2025 huyubiao - 2.37-27 +- DESC:back port PR29171 to fix invalid read causing SIGSEGV + * Sat Oct 12 2024 liningjie - 2.37-26 - DESC:fix ref leak of names of newly-inserted non-root-visible types -- Gitee