diff --git a/Fix-tekhex-object-file-output.patch b/Fix-tekhex-object-file-output.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a50a5733e9b54f86635c611dc4dce798e8473b1 --- /dev/null +++ b/Fix-tekhex-object-file-output.patch @@ -0,0 +1,92 @@ +From e0323071916878e0634a6e24d8250e4faff67e88 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Mon, 11 Nov 2024 10:24:09 +1030 +Subject: [PATCH] Re: tekhex object file output fixes + +Commit 8b5a212495 supported *ABS* symbols by allowing "section" to be +bfd_abs_section, but bfd_abs_section needs to be treated specially. +In particular, bfd_get_next_section_by_name (.., bfd_abs_section_ptr) +is invalid. + + PR 32347 + * tekhex.c (first_phase): Guard against modification of + _bfd_std_section[] entries. +--- + bfd/tekhex.c | 38 ++++++++++++++++++++------------------ + 1 file changed, 20 insertions(+), 18 deletions(-) + +diff --git a/bfd/tekhex.c b/bfd/tekhex.c +index aea2ebb23df..b305c1f96f1 100644 +--- a/bfd/tekhex.c ++++ b/bfd/tekhex.c +@@ -361,6 +361,7 @@ first_phase (bfd *abfd, int type, char *src, char * src_end) + { + asection *section, *alt_section; + unsigned int len; ++ bfd_vma addr; + bfd_vma val; + char sym[17]; /* A symbol can only be 16chars long. */ + +@@ -368,20 +369,16 @@ first_phase (bfd *abfd, int type, char *src, char * src_end) + { + case '6': + /* Data record - read it and store it. */ +- { +- bfd_vma addr; +- +- if (!getvalue (&src, &addr, src_end)) +- return false; +- +- while (*src && src < src_end - 1) +- { +- insert_byte (abfd, HEX (src), addr); +- src += 2; +- addr++; +- } +- return true; +- } ++ if (!getvalue (&src, &addr, src_end)) ++ return false; ++ ++ while (*src && src < src_end - 1) ++ { ++ insert_byte (abfd, HEX (src), addr); ++ src += 2; ++ addr++; ++ } ++ return true; + + case '3': + /* Symbol record, read the segment. */ +@@ -406,13 +403,16 @@ first_phase (bfd *abfd, int type, char *src, char * src_end) + { + case '1': /* Section range. */ + src++; +- if (!getvalue (&src, §ion->vma, src_end)) ++ if (!getvalue (&src, &addr, src_end)) + return false; + if (!getvalue (&src, &val, src_end)) + return false; +- if (val < section->vma) +- val = section->vma; +- section->size = val - section->vma; ++ if (bfd_is_const_section (section)) ++ break; ++ section->vma = addr; ++ if (val < addr) ++ val = addr; ++ section->size = val - addr; + /* PR 17512: file: objdump-s-endless-loop.tekhex. + Check for overlarge section sizes. */ + if (section->size & 0x80000000) +@@ -455,6 +455,8 @@ first_phase (bfd *abfd, int type, char *src, char * src_end) + new_symbol->symbol.flags = BSF_LOCAL; + if (stype == '2' || stype == '6') + new_symbol->symbol.section = bfd_abs_section_ptr; ++ else if (bfd_is_const_section (section)) ++ ; + else if (stype == '3' || stype == '7') + { + if ((section->flags & SEC_DATA) == 0) +-- +2.43.5 diff --git a/binutils.spec b/binutils.spec index 1e8054c9f3c6decaf5d4c51635bc970baff96aa8..c519b64e952dd40ce641514b2bc08ad270da6a5e 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: binutils%{?_with_debug:-debug} Version: 2.41 -Release: 12 +Release: 13 License: GPL-3.0-or-later AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND (LGPL-2.0-or-later WITH GCC-exception-2.0) AND BSD-3-Clause AND GFDL-1.3-or-later AND GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later URL: https://sourceware.org/binutils @@ -356,6 +356,9 @@ Patch5008: binutils-gold-empty-dwp.patch # Lifetime: Permanent Patch5009: Fix-gold-linker-relocation-offset.patch +# Purpose: Fix tekhex object file output, Fix CVE-2024-53589. +# Lifetime: Permanent. +Patch5010: Fix-tekhex-object-file-output.patch #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -1370,6 +1373,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Thu Dec 12 2024 ZhaoYu Jiang - 2.41-13 +- Fix ObjDump CVE-2024-53589: Buffer Overflow in GNU Binutils objdump tekhex Parser. + * Fri Nov 22 2024 swcompiler - 2.41-12 - Sw64 add sw64 ISA support