Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-2.0.git;a=commitdiff;h=aa41bf69a6c57a1e0875f80869353be0d35caae0
commit aa41bf69a6c57a1e0875f80869353be0d35caae0 Author: kikadf <[email protected]> Date: Sat Feb 28 08:12:09 2015 +0100 binutils-2.24-5rigel1-x86_64 * Fix CVE-2014-8484, CVE-2014-8485, CVE-2014-8501, CVE-2014-8502, * CVE-2014-8503, CVE-2014-8504, CVE-2014-8737, CVE-2014-8738 diff --git a/source/devel/binutils/CVE-2014-8484.patch b/source/devel/binutils/CVE-2014-8484.patch new file mode 100644 index 0000000..1a90eff --- /dev/null +++ b/source/devel/binutils/CVE-2014-8484.patch @@ -0,0 +1,52 @@ +From bd25671c6f202c4a5108883caa2adb24ff6f361f Mon Sep 17 00:00:00 2001 +From: Alan Modra <[email protected]> +Date: Fri, 29 Aug 2014 10:36:29 +0930 +Subject: [PATCH] Report an error for S-records with less than the miniumum size + + * srec.c (srec_scan): Revert last change. Report an error for + S-records with less than the miniumum byte count. + +[Ubuntu note: patch differs from upstream by removing the changelog +update, and the reversion of the previous svn commit. -- sbeattie] + +CVE-2014-8484 +--- + bfd/srec.c | 18 +++++++++++++++--- + 2 files changed, 20 insertions(+), 3 deletions(-) + +diff --git a/bfd/srec.c b/bfd/srec.c +index d979bf5..42143c7 100644 +--- a/bfd/srec.c ++++ b/bfd/srec.c +@@ -453,7 +453,7 @@ srec_scan (bfd *abfd) + { + file_ptr pos; + char hdr[3]; +- unsigned int bytes; ++ unsigned int bytes, min_bytes; + bfd_vma address; + bfd_byte *data; + unsigned char check_sum; +@@ -476,6 +476,19 @@ srec_scan (bfd *abfd) + } + + check_sum = bytes = HEX (hdr + 1); ++ min_bytes = 3; ++ if (hdr[0] == '2' || hdr[0] == '8') ++ min_bytes = 4; ++ else if (hdr[0] == '3' || hdr[0] == '7') ++ min_bytes = 5; ++ if (bytes < min_bytes) ++ { ++ (*_bfd_error_handler) (_("%B:%d: byte count %d too small\n"), ++ abfd, lineno, bytes); ++ bfd_set_error (bfd_error_bad_value); ++ goto error_return; ++ } ++ + if (bytes * 2 > bufsize) + { + if (buf != NULL) +-- +1.7.1 + diff --git a/source/devel/binutils/CVE-2014-8485.patch b/source/devel/binutils/CVE-2014-8485.patch new file mode 100644 index 0000000..e4b5666 --- /dev/null +++ b/source/devel/binutils/CVE-2014-8485.patch @@ -0,0 +1,90 @@ +From 493a33860c71cac998f1a56d6d87d6faa801fbaa Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Mon, 27 Oct 2014 12:43:16 +0000 +Subject: [PATCH] This patch closes a potential security hole in applications that use + the bfd library to parse binaries containing maliciously corrupt section + group headers. + + PR binutils/17510 + * elf.c (setup_group): Improve handling of corrupt group + sections. + +[Ubuntu note: this patch differs from upstream by dropping the Changelog +entry to reduce patch conflicts. -- sbeattie] + +CVE-2014-8485 + +--- + bfd/elf.c | 34 ++++++++++++++++++++++++++++++---- + 2 files changed, 36 insertions(+), 4 deletions(-) + +diff --git a/bfd/elf.c b/bfd/elf.c +index c884d1d..c8ac826 100644 +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -608,9 +608,10 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) + if (shdr->contents == NULL) + { + _bfd_error_handler +- (_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); ++ (_("%B: corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); + bfd_set_error (bfd_error_bad_value); +- return FALSE; ++ -- num_group; ++ continue; + } + + memset (shdr->contents, 0, amt); +@@ -618,8 +619,17 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) + if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0 + || (bfd_bread (shdr->contents, shdr->sh_size, abfd) + != shdr->sh_size)) +- return FALSE; +- ++ { ++ _bfd_error_handler ++ (_("%B: invalid size field in group section header: 0x%lx"), abfd, shdr->sh_size); ++ bfd_set_error (bfd_error_bad_value); ++ -- num_group; ++ /* PR 17510: If the group contents are even partially ++ corrupt, do not allow any of the contents to be used. */ ++ memset (shdr->contents, 0, amt); ++ continue; ++ } ++ + /* Translate raw contents, a flag word followed by an + array of elf section indices all in target byte order, + to the flag word followed by an array of elf section +@@ -651,6 +661,21 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) + } + } + } ++ ++ /* PR 17510: Corrupt binaries might contain invalid groups. */ ++ if (num_group != (unsigned) elf_tdata (abfd)->num_group) ++ { ++ elf_tdata (abfd)->num_group = num_group; ++ ++ /* If all groups are invalid then fail. */ ++ if (num_group == 0) ++ { ++ elf_tdata (abfd)->group_sect_ptr = NULL; ++ elf_tdata (abfd)->num_group = num_group = -1; ++ (*_bfd_error_handler) (_("%B: no valid group sections found"), abfd); ++ bfd_set_error (bfd_error_bad_value); ++ } ++ } + } + } + +@@ -716,6 +741,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) + { + (*_bfd_error_handler) (_("%B: no group info for section %A"), + abfd, newsect); ++ return FALSE; + } + return TRUE; + } +-- +1.7.1 + diff --git a/source/devel/binutils/CVE-2014-8501.patch b/source/devel/binutils/CVE-2014-8501.patch new file mode 100644 index 0000000..4e40126 --- /dev/null +++ b/source/devel/binutils/CVE-2014-8501.patch @@ -0,0 +1,42 @@ +From 7e1e19887abd24aeb15066b141cdff5541e0ec8e Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Mon, 27 Oct 2014 14:45:06 +0000 +Subject: [PATCH] Fix a seg-fault in strings and other binutuils when parsing a corrupt PE + executable with an invalid value in the NumberOfRvaAndSizes field of the + AOUT header. + + PR binutils/17512 + * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Handle corrupt binaries + with an invalid value for NumberOfRvaAndSizes. + +[Ubuntu note: patch differs from upstream commit in that it drops the +changelog update to reduce patch conflicts. --sbeattie] + +CVE-2014-8501 +--- + bfd/peXXigen.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +Index: b/bfd/peXXigen.c +=================================================================== +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -460,6 +460,18 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, + { + int idx; + ++ /* PR 17512: Corrupt PE binaries can cause seg-faults. */ ++ if (a->NumberOfRvaAndSizes > 16) ++ { ++ (*_bfd_error_handler) ++ (_("%B: aout header specifies an invalid number of data-directory entries: %d"), ++ abfd, a->NumberOfRvaAndSizes); ++ /* Paranoia: If the number is corrupt, then assume that the ++ actual entries themselves might be corrupt as well. */ ++ a->NumberOfRvaAndSizes = 0; ++ } ++ ++ + for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++) + { + /* If data directory is empty, rva also should be 0. */ diff --git a/source/devel/binutils/CVE-2014-8502.patch b/source/devel/binutils/CVE-2014-8502.patch new file mode 100644 index 0000000..37eda5a --- /dev/null +++ b/source/devel/binutils/CVE-2014-8502.patch @@ -0,0 +1,630 @@ +From b69c87280595b7ce4e956cb2a62278412f0722f7 Mon Sep 17 00:00:00 2001 +From: Jon Turney <[email protected]> +Date: Thu, 3 Apr 2014 12:26:27 +0100 +Subject: [PATCH] * peXXigen.c (pe_print_edata): Verify edt.name lies inside + section before dereferencing. + (pe_print_idata, pe_print_edata, pe_print_reloc) + (rsrc_print_section): Don't bother interpreting the contents + of sections which have no contents. + +From b2f93c5011cab00f31669363577b938697752e43 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Tue, 28 Oct 2014 10:50:17 +0000 +Subject: [PATCH] Import patches from the master branch which prevent seg-faults when parsing + corrupt binaries. + + 2014-10-27 Nick Clifton <[email protected]> + PR binutils/17512 + * elf.c (bfd_section_from_shdr): Detect and warn about ELF + binaries with a group of sections linked by the string table + indicies. + * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Handle corrupt binaries + with an invalid value for NumberOfRvaAndSizes. + (pe_print_edata): Detect out of range rvas and entry counts for + the Export Address table, Name Pointer table and Ordinal table. + + PR binutils/17510 + * elf.c (setup_group): Improve handling of corrupt group + sections. + +From 5a4b0ccc20ba30caef53b01bee2c0aaa5b855339 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Tue, 28 Oct 2014 15:42:56 +0000 +Subject: [PATCH] More fixes for corrupt binaries crashing the binutils. + + PR binutils/17512 + * elf.c (bfd_section_from_shdr): Allocate and free the recursion + detection table on a per-bfd basis. + * peXXigen.c (pe_print_edata): Handle binaries with a truncated + export table. + +From e5b470e24ce448a56230137a37d3b17299593041 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Wed, 29 Oct 2014 20:58:13 +0000 +Subject: [PATCH] Fixes another memory corruption bug introduced by patches for PR 17512. + + * elf.c (bfd_section_from_shdr): Fix heap use after free memory + leak. + +[Ubuntu note: patch differs from upstream commits in that it drops +the changelog entry to reduce patch conflicts, the first patches +fix to rsrc_print_section as it doesn't exist yet, and the second +commit's fixes to handle srec, as that's already covered by the +binutils-CVE-2014-8504.patch. -- sbeattie] + +Third commit fixes CVE-2014-8502, but first two commits are needed as +prerequisites, and the last one fixes a use-after-free introduced by +earlier patches. + +--- + bfd/elf.c | 204 ++++++++++++++++++++++++++++++++++++++------------------- + bfd/peXXigen.c | 55 ++++++++++++--- + 2 files changed, 185 insertions(+), 74 deletions(-) + +Index: b/bfd/peXXigen.c +=================================================================== +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -1115,6 +1115,13 @@ pe_print_idata (bfd * abfd, void * vfile + _("\nThere is an import table, but the section containing it could not be found\n")); + return TRUE; + } ++ else if (!(section->flags & SEC_HAS_CONTENTS)) ++ { ++ fprintf (file, ++ _("\nThere is an import table in %s, but that section has no contents\n"), ++ section->name); ++ return TRUE; ++ } + } + + fprintf (file, _("\nThere is an import table in %s at 0x%lx\n"), +@@ -1376,7 +1383,7 @@ pe_print_edata (bfd * abfd, void * vfile + bfd_size_type datasize = 0; + bfd_size_type dataoff; + bfd_size_type i; +- bfd_signed_vma adj; ++ bfd_vma adj; + struct EDT_type + { + long export_flags; /* Reserved - should be zero. */ +@@ -1426,6 +1433,13 @@ pe_print_edata (bfd * abfd, void * vfile + _("\nThere is an export table, but the section containing it could not be found\n")); + return TRUE; + } ++ else if (!(section->flags & SEC_HAS_CONTENTS)) ++ { ++ fprintf (file, ++ _("\nThere is an export table in %s, but that section has no contents\n"), ++ section->name); ++ return TRUE; ++ } + + dataoff = addr - section->vma; + datasize = extra->DataDirectory[PE_EXPORT_TABLE].Size; +@@ -1438,6 +1452,15 @@ pe_print_edata (bfd * abfd, void * vfile + } + } + ++ /* PR 17512: Handle corrupt PE binaries. */ ++ if (datasize < 36) ++ { ++ fprintf (file, ++ _("\nThere is an export table in %s, but it is too small (%d)\n"), ++ section->name, (int) datasize); ++ return TRUE; ++ } ++ + fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"), + section->name, (unsigned long) addr); + +@@ -1481,8 +1504,11 @@ pe_print_edata (bfd * abfd, void * vfile + fprintf (file, + _("Name \t\t\t\t")); + bfd_fprintf_vma (abfd, file, edt.name); +- fprintf (file, +- " %s\n", data + edt.name - adj); ++ ++ if ((edt.name >= adj) && (edt.name < adj + datasize)) ++ fprintf (file, " %s\n", data + edt.name - adj); ++ else ++ fprintf (file, "(outside .edata section)\n"); + + fprintf (file, + _("Ordinal Base \t\t\t%ld\n"), edt.base); +@@ -1528,7 +1554,12 @@ pe_print_edata (bfd * abfd, void * vfile + _("\nExport Address Table -- Ordinal Base %ld\n"), + edt.base); + +- for (i = 0; i < edt.num_functions; ++i) ++ /* PR 17512: Handle corrupt PE binaries. */ ++ if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize) ++ fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"), ++ (long) edt.eat_addr, ++ (long) edt.num_functions); ++ else for (i = 0; i < edt.num_functions; ++i) + { + bfd_vma eat_member = bfd_get_32 (abfd, + data + edt.eat_addr + (i * 4) - adj); +@@ -1564,7 +1595,16 @@ pe_print_edata (bfd * abfd, void * vfile + fprintf (file, + _("\n[Ordinal/Name Pointer] Table\n")); + +- for (i = 0; i < edt.num_names; ++i) ++ /* PR 17512: Handle corrupt PE binaries. */ ++ if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize) ++ fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"), ++ (long) edt.npt_addr, ++ (long) edt.num_names); ++ else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize) ++ fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"), ++ (long) edt.ot_addr, ++ (long) edt.num_names); ++ else for (i = 0; i < edt.num_names; ++i) + { + bfd_vma name_ptr = bfd_get_32 (abfd, + data + +@@ -1930,10 +1970,7 @@ pe_print_reloc (bfd * abfd, void * vfile + bfd_size_type i; + bfd_size_type start, stop; + +- if (section == NULL) +- return TRUE; +- +- if (section->size == 0) ++ if (section == NULL || section->size == 0 || !(section->flags & SEC_HAS_CONTENTS)) + return TRUE; + + fprintf (file, +Index: b/bfd/elf.c +=================================================================== +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -1574,38 +1574,74 @@ bfd_section_from_shdr (bfd *abfd, unsign + Elf_Internal_Ehdr *ehdr; + const struct elf_backend_data *bed; + const char *name; ++ bfd_boolean ret = TRUE; ++ static bfd_boolean * sections_being_created = NULL; ++ static bfd * sections_being_created_abfd = NULL; ++ static unsigned int nesting = 0; + + if (shindex >= elf_numsections (abfd)) + return FALSE; + ++ if (++ nesting > 3) ++ { ++ /* PR17512: A corrupt ELF binary might contain a recursive group of ++ sections, each the string indicies pointing to the next in the ++ loop. Detect this here, by refusing to load a section that we are ++ already in the process of loading. We only trigger this test if ++ we have nested at least three sections deep as normal ELF binaries ++ can expect to recurse at least once. ++ ++ FIXME: It would be better if this array was attached to the bfd, ++ rather than being held in a static pointer. */ ++ ++ if (sections_being_created_abfd != abfd) ++ sections_being_created = NULL; ++ if (sections_being_created == NULL) ++ { ++ /* FIXME: It would be more efficient to attach this array to the bfd somehow. */ ++ sections_being_created = (bfd_boolean *) ++ bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean)); ++ sections_being_created_abfd = abfd; ++ } ++ if (sections_being_created [shindex]) ++ { ++ (*_bfd_error_handler) ++ (_("%B: warning: loop in section dependencies detected"), abfd); ++ return FALSE; ++ } ++ sections_being_created [shindex] = TRUE; ++ } ++ + hdr = elf_elfsections (abfd)[shindex]; + ehdr = elf_elfheader (abfd); + name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx, + hdr->sh_name); + if (name == NULL) +- return FALSE; ++ goto fail; + + bed = get_elf_backend_data (abfd); + switch (hdr->sh_type) + { + case SHT_NULL: + /* Inactive section. Throw it away. */ +- return TRUE; ++ goto success; + +- case SHT_PROGBITS: /* Normal section with contents. */ +- case SHT_NOBITS: /* .bss section. */ +- case SHT_HASH: /* .hash section. */ +- case SHT_NOTE: /* .note section. */ ++ case SHT_PROGBITS: /* Normal section with contents. */ ++ case SHT_NOBITS: /* .bss section. */ ++ case SHT_HASH: /* .hash section. */ ++ case SHT_NOTE: /* .note section. */ + case SHT_INIT_ARRAY: /* .init_array section. */ + case SHT_FINI_ARRAY: /* .fini_array section. */ + case SHT_PREINIT_ARRAY: /* .preinit_array section. */ + case SHT_GNU_LIBLIST: /* .gnu.liblist section. */ + case SHT_GNU_HASH: /* .gnu.hash section. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_DYNAMIC: /* Dynamic linking information. */ + if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) +- return FALSE; ++ goto fail; ++ + if (hdr->sh_link > elf_numsections (abfd)) + { + /* PR 10478: Accept Solaris binaries with a sh_link +@@ -1619,11 +1655,11 @@ bfd_section_from_shdr (bfd *abfd, unsign + break; + /* Otherwise fall through. */ + default: +- return FALSE; ++ goto fail; + } + } + else if (elf_elfsections (abfd)[hdr->sh_link] == NULL) +- return FALSE; ++ goto fail; + else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) + { + Elf_Internal_Shdr *dynsymhdr; +@@ -1652,24 +1688,26 @@ bfd_section_from_shdr (bfd *abfd, unsign + } + } + } +- break; ++ goto success; + +- case SHT_SYMTAB: /* A symbol table */ ++ case SHT_SYMTAB: /* A symbol table. */ + if (elf_onesymtab (abfd) == shindex) +- return TRUE; ++ goto success; + + if (hdr->sh_entsize != bed->s->sizeof_sym) +- return FALSE; ++ goto fail; ++ + if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) + { + if (hdr->sh_size != 0) +- return FALSE; ++ goto fail; + /* Some assemblers erroneously set sh_info to one with a + zero sh_size. ld sees this as a global symbol count + of (unsigned) -1. Fix it here. */ + hdr->sh_info = 0; +- return TRUE; ++ goto success; + } ++ + BFD_ASSERT (elf_onesymtab (abfd) == 0); + elf_onesymtab (abfd) = shindex; + elf_tdata (abfd)->symtab_hdr = *hdr; +@@ -1686,7 +1724,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + && (abfd->flags & DYNAMIC) != 0 + && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name, + shindex)) +- return FALSE; ++ goto fail; + + /* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we + can't read symbols without that section loaded as well. It +@@ -1712,26 +1750,29 @@ bfd_section_from_shdr (bfd *abfd, unsign + break; + } + if (i != shindex) +- return bfd_section_from_shdr (abfd, i); ++ ret = bfd_section_from_shdr (abfd, i); + } +- return TRUE; ++ goto success; + +- case SHT_DYNSYM: /* A dynamic symbol table */ ++ case SHT_DYNSYM: /* A dynamic symbol table. */ + if (elf_dynsymtab (abfd) == shindex) +- return TRUE; ++ goto success; + + if (hdr->sh_entsize != bed->s->sizeof_sym) +- return FALSE; ++ goto fail; ++ + if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) + { + if (hdr->sh_size != 0) +- return FALSE; ++ goto fail; ++ + /* Some linkers erroneously set sh_info to one with a + zero sh_size. ld sees this as a global symbol count + of (unsigned) -1. Fix it here. */ + hdr->sh_info = 0; +- return TRUE; ++ goto success; + } ++ + BFD_ASSERT (elf_dynsymtab (abfd) == 0); + elf_dynsymtab (abfd) = shindex; + elf_tdata (abfd)->dynsymtab_hdr = *hdr; +@@ -1740,34 +1781,38 @@ bfd_section_from_shdr (bfd *abfd, unsign + + /* Besides being a symbol table, we also treat this as a regular + section, so that objcopy can handle it. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + +- case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */ ++ case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */ + if (elf_symtab_shndx (abfd) == shindex) +- return TRUE; ++ goto success; + + BFD_ASSERT (elf_symtab_shndx (abfd) == 0); + elf_symtab_shndx (abfd) = shindex; + elf_tdata (abfd)->symtab_shndx_hdr = *hdr; + elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr; +- return TRUE; ++ goto success; + +- case SHT_STRTAB: /* A string table */ ++ case SHT_STRTAB: /* A string table. */ + if (hdr->bfd_section != NULL) +- return TRUE; ++ goto success; ++ + if (ehdr->e_shstrndx == shindex) + { + elf_tdata (abfd)->shstrtab_hdr = *hdr; + elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr; +- return TRUE; ++ goto success; + } ++ + if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex) + { + symtab_strtab: + elf_tdata (abfd)->strtab_hdr = *hdr; + elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr; +- return TRUE; ++ goto success; + } ++ + if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex) + { + dynsymtab_strtab: +@@ -1776,8 +1821,9 @@ bfd_section_from_shdr (bfd *abfd, unsign + elf_elfsections (abfd)[shindex] = hdr; + /* We also treat this as a regular section, so that objcopy + can handle it. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, +- shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, ++ shindex); ++ goto success; + } + + /* If the string table isn't one of the above, then treat it as a +@@ -1795,9 +1841,9 @@ bfd_section_from_shdr (bfd *abfd, unsign + { + /* Prevent endless recursion on broken objects. */ + if (i == shindex) +- return FALSE; ++ goto fail; + if (! bfd_section_from_shdr (abfd, i)) +- return FALSE; ++ goto fail; + if (elf_onesymtab (abfd) == i) + goto symtab_strtab; + if (elf_dynsymtab (abfd) == i) +@@ -1805,7 +1851,8 @@ bfd_section_from_shdr (bfd *abfd, unsign + } + } + } +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_REL: + case SHT_RELA: +@@ -1820,7 +1867,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + if (hdr->sh_entsize + != (bfd_size_type) (hdr->sh_type == SHT_REL + ? bed->s->sizeof_rel : bed->s->sizeof_rela)) +- return FALSE; ++ goto fail; + + /* Check for a bogus link to avoid crashing. */ + if (hdr->sh_link >= num_sec) +@@ -1828,8 +1875,9 @@ bfd_section_from_shdr (bfd *abfd, unsign + ((*_bfd_error_handler) + (_("%B: invalid link %lu for reloc section %s (index %u)"), + abfd, hdr->sh_link, name, shindex)); +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, +- shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, ++ shindex); ++ goto success; + } + + /* For some incomprehensible reason Oracle distributes +@@ -1870,7 +1918,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB + || elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM) + && ! bfd_section_from_shdr (abfd, hdr->sh_link)) +- return FALSE; ++ goto fail; + + /* If this reloc section does not use the main symbol table we + don't treat it as a reloc section. BFD can't adequately +@@ -1885,14 +1933,18 @@ bfd_section_from_shdr (bfd *abfd, unsign + || hdr->sh_info >= num_sec + || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL + || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA) +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, +- shindex); ++ { ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, ++ shindex); ++ goto success; ++ } + + if (! bfd_section_from_shdr (abfd, hdr->sh_info)) +- return FALSE; ++ goto fail; ++ + target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info); + if (target_sect == NULL) +- return FALSE; ++ goto fail; + + esdt = elf_section_data (target_sect); + if (hdr->sh_type == SHT_RELA) +@@ -1904,7 +1956,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + amt = sizeof (*hdr2); + hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); + if (hdr2 == NULL) +- return FALSE; ++ goto fail; + *hdr2 = *hdr; + *p_hdr = hdr2; + elf_elfsections (abfd)[shindex] = hdr2; +@@ -1920,34 +1972,40 @@ bfd_section_from_shdr (bfd *abfd, unsign + target_sect->use_rela_p = 1; + } + abfd->flags |= HAS_RELOC; +- return TRUE; ++ goto success; + } + + case SHT_GNU_verdef: + elf_dynverdef (abfd) = shindex; + elf_tdata (abfd)->dynverdef_hdr = *hdr; +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_GNU_versym: + if (hdr->sh_entsize != sizeof (Elf_External_Versym)) +- return FALSE; ++ goto fail; ++ + elf_dynversym (abfd) = shindex; + elf_tdata (abfd)->dynversym_hdr = *hdr; +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_GNU_verneed: + elf_dynverref (abfd) = shindex; + elf_tdata (abfd)->dynverref_hdr = *hdr; +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_SHLIB: +- return TRUE; ++ goto success; + + case SHT_GROUP: + if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE)) +- return FALSE; ++ goto fail; ++ + if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) +- return FALSE; ++ goto fail; ++ + if (hdr->contents != NULL) + { + Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents; +@@ -1973,7 +2031,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + } + } + } +- break; ++ goto success; + + default: + /* Possibly an attributes section. */ +@@ -1981,14 +2039,14 @@ bfd_section_from_shdr (bfd *abfd, unsign + || hdr->sh_type == bed->obj_attrs_section_type) + { + if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) +- return FALSE; ++ goto fail; + _bfd_elf_parse_attributes (abfd, hdr); +- return TRUE; ++ goto success; + } + + /* Check for any processor-specific section types. */ + if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex)) +- return TRUE; ++ goto success; + + if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER) + { +@@ -2000,9 +2058,12 @@ bfd_section_from_shdr (bfd *abfd, unsign + "specific section `%s' [0x%8x]"), + abfd, name, hdr->sh_type); + else +- /* Allow sections reserved for applications. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, +- shindex); ++ { ++ /* Allow sections reserved for applications. */ ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, ++ shindex); ++ goto success; ++ } + } + else if (hdr->sh_type >= SHT_LOPROC + && hdr->sh_type <= SHT_HIPROC) +@@ -2023,8 +2084,11 @@ bfd_section_from_shdr (bfd *abfd, unsign + "`%s' [0x%8x]"), + abfd, name, hdr->sh_type); + else +- /* Otherwise it should be processed. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ { ++ /* Otherwise it should be processed. */ ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; ++ } + } + else + /* FIXME: We should handle this section. */ +@@ -2032,10 +2096,20 @@ bfd_section_from_shdr (bfd *abfd, unsign + (_("%B: don't know how to handle section `%s' [0x%8x]"), + abfd, name, hdr->sh_type); + +- return FALSE; ++ goto fail; + } + +- return TRUE; ++ fail: ++ ret = FALSE; ++ success: ++ if (sections_being_created && sections_being_created_abfd == abfd) ++ sections_being_created [shindex] = FALSE; ++ if (-- nesting == 0) ++ { ++ sections_being_created = NULL; ++ sections_being_created_abfd = abfd; ++ } ++ return ret; + } + + /* Return the local symbol specified by ABFD, R_SYMNDX. */ diff --git a/source/devel/binutils/CVE-2014-8503.patch b/source/devel/binutils/CVE-2014-8503.patch new file mode 100644 index 0000000..db4b1c5 --- /dev/null +++ b/source/devel/binutils/CVE-2014-8503.patch @@ -0,0 +1,33 @@ +From 0102ea8cec5fc509bba6c91df61b7ce23a799d32 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Thu, 30 Oct 2014 17:16:17 +0000 +Subject: [PATCH] Fixes a seg-fault in the ihex parser when it encounters a malformed ihex file. + + PR binutils/17512 + * ihex.c (ihex_scan): Fix typo in invocation of ihex_bad_byte. + +[Ubuntu note: patch differs from upstream commit in that it drops the +changelog entry to reduce patch conflicts. -- sbeattie] + +CVE-2014-8503 +--- + bfd/ChangeLog | 1 + + bfd/ihex.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/bfd/ihex.c b/bfd/ihex.c +index 8d3590d..9b3b813 100644 +--- a/bfd/ihex.c ++++ b/bfd/ihex.c +@@ -321,7 +321,7 @@ ihex_scan (bfd *abfd) + { + if (! ISHEX (buf[i])) + { +- ihex_bad_byte (abfd, lineno, hdr[i], error); ++ ihex_bad_byte (abfd, lineno, buf[i], error); + goto error_return; + } + } +-- +1.7.1 + diff --git a/source/devel/binutils/CVE-2014-8504.patch b/source/devel/binutils/CVE-2014-8504.patch new file mode 100644 index 0000000..8a8c577 --- /dev/null +++ b/source/devel/binutils/CVE-2014-8504.patch @@ -0,0 +1,48 @@ +From 708d7d0d11f0f2d776171979aa3479e8e12a38a0 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Tue, 28 Oct 2014 10:48:14 +0000 +Subject: [PATCH] This patch fixes a flaw in the SREC parser which could cause a stack overflow + and potential secuiryt breach. + + PR binutils/17510 + * srec.c (srec_bad_byte): Increase size of buf to allow for + negative values. + (srec_scan): Use an unsigned char buffer to hold header bytes. + +[Ubuntu note: patch differs from upstream commit in that it drops the +changelog entry and the cosmetic whitespace changes to reduce patch +conflicts. -- sbeattie] + +CVE-2014-8504 +--- + bfd/ChangeLog | 8 ++++++++ + bfd/elf.c | 2 +- + bfd/peXXigen.c | 1 - + bfd/srec.c | 4 ++-- + 4 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/bfd/srec.c b/bfd/srec.c +index 9ed2080..5f9a546 100644 +--- a/bfd/srec.c ++++ b/bfd/srec.c +@@ -246,7 +246,7 @@ srec_bad_byte (bfd *abfd, + } + else + { +- char buf[10]; ++ char buf[40]; + + if (! ISPRINT (c)) + sprintf (buf, "\\%03o", (unsigned int) c); +@@ -452,7 +452,7 @@ srec_scan (bfd *abfd) + case 'S': + { + file_ptr pos; +- char hdr[3]; ++ unsigned char hdr[3]; + unsigned int bytes, min_bytes; + bfd_vma address; + bfd_byte *data; +-- +1.7.1 + diff --git a/source/devel/binutils/CVE-2014-8737.patch b/source/devel/binutils/CVE-2014-8737.patch new file mode 100644 index 0000000..80a2392 --- /dev/null +++ b/source/devel/binutils/CVE-2014-8737.patch @@ -0,0 +1,208 @@ +From dd9b91de2149ee81d47f708e7b0bbf57da10ad42 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Thu, 6 Nov 2014 14:49:10 +0000 +Subject: [PATCH] Prevent archive memebers with illegal pathnames from being extracted from an archive. + + PR binutils/17552, binutils/17533 + * bucomm.c (is_valid_archive_path): New function. Returns false + for absolute pathnames and pathnames that include /../. + * bucomm.h (is_valid_archive_path): Add prototype. + * ar.c (extract_file): Use new function to check for valid + pathnames when extracting files from an archive. + * objcopy.c (copy_archive): Likewise. + * doc/binutils.texi: Update documentation to mention the + limitation on pathname of archive members. + +From 5e186ece2feebb46e63ff6bb2d2490aad0d5a724 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Mon, 10 Nov 2014 14:28:43 +0000 +Subject: [PATCH] Fix objcopy and strip so that they remove their temporary files even if an error occurs. + + PR binutils/17552 + * (copy_archive): Clean up temporary files even if an error + occurs. + +[Ubuntu note: patches differ from upstream commit by dropping the +changelog updates to reduce patch conflicts. -- sbeattie] + +CVE-2014-8737 + fix to clean up temporary files on error +--- + binutils/ar.c | 9 +++++++++ + binutils/bucomm.c | 26 ++++++++++++++++++++++++++ + binutils/bucomm.h | 12 ++++++++---- + binutils/doc/binutils.texi | 3 ++- + binutils/objcopy.c | 23 ++++++++++++++++++----- + 5 files changed, 63 insertions(+), 10 deletions(-) + +Index: b/binutils/ar.c +=================================================================== +--- a/binutils/ar.c ++++ b/binutils/ar.c +@@ -1031,6 +1031,15 @@ extract_file (bfd *abfd) + bfd_size_type size; + struct stat buf; + ++ /* PR binutils/17533: Do not allow directory traversal ++ outside of the current directory tree. */ ++ if (! is_valid_archive_path (bfd_get_filename (abfd))) ++ { ++ non_fatal (_("illegal pathname found in archive member: %s"), ++ bfd_get_filename (abfd)); ++ return; ++ } ++ + if (bfd_stat_arch_elt (abfd, &buf) != 0) + /* xgettext:c-format */ + fatal (_("internal stat error on %s"), bfd_get_filename (abfd)); +Index: b/binutils/bucomm.c +=================================================================== +--- a/binutils/bucomm.c ++++ b/binutils/bucomm.c +@@ -624,3 +624,29 @@ bfd_get_archive_filename (const bfd *abf + bfd_get_filename (abfd)); + return buf; + } ++ ++/* Returns TRUE iff PATHNAME, a filename of an archive member, ++ is valid for writing. For security reasons absolute paths ++ and paths containing /../ are not allowed. See PR 17533. */ ++ ++bfd_boolean ++is_valid_archive_path (char const * pathname) ++{ ++ const char * n = pathname; ++ ++ if (IS_ABSOLUTE_PATH (n)) ++ return FALSE; ++ ++ while (*n) ++ { ++ if (*n == '.' && *++n == '.' && ( ! *++n || IS_DIR_SEPARATOR (*n))) ++ return FALSE; ++ ++ while (*n && ! IS_DIR_SEPARATOR (*n)) ++ n++; ++ while (IS_DIR_SEPARATOR (*n)) ++ n++; ++ } ++ ++ return TRUE; ++} +Index: b/binutils/bucomm.h +=================================================================== +--- a/binutils/bucomm.h ++++ b/binutils/bucomm.h +@@ -23,6 +23,8 @@ + #ifndef _BUCOMM_H + #define _BUCOMM_H + ++/* In bucomm.c. */ ++ + /* Return the filename in a static buffer. */ + const char *bfd_get_archive_filename (const bfd *); + +@@ -58,20 +60,22 @@ bfd_vma parse_vma (const char *, const c + + off_t get_file_size (const char *); + ++bfd_boolean is_valid_archive_path (char const *); ++ + extern char *program_name; + +-/* filemode.c */ ++/* In filemode.c. */ + void mode_string (unsigned long, char *); + +-/* version.c */ ++/* In version.c. */ + extern void print_version (const char *); + +-/* rename.c */ ++/* In rename.c. */ + extern void set_times (const char *, const struct stat *); + + extern int smart_rename (const char *, const char *, int); + +-/* libiberty. */ ++/* In libiberty. */ + void *xmalloc (size_t); + + void *xrealloc (void *, size_t); +Index: b/binutils/doc/binutils.texi +=================================================================== +--- a/binutils/doc/binutils.texi ++++ b/binutils/doc/binutils.texi +@@ -234,7 +234,8 @@ a normal archive. Instead the elements + individually to the second archive. + + The paths to the elements of the archive are stored relative to the +-archive itself. ++archive itself. For security reasons absolute paths and paths with a ++@code{/../} component are not allowed. + + @cindex compatibility, @command{ar} + @cindex @command{ar} compatibility +Index: b/binutils/objcopy.c +=================================================================== +--- a/binutils/objcopy.c ++++ b/binutils/objcopy.c +@@ -2206,6 +2206,16 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + bfd_boolean del = TRUE; + bfd_boolean ok_object; + ++ /* PR binutils/17533: Do not allow directory traversal ++ outside of the current directory tree by archive members. */ ++ if (! is_valid_archive_path (bfd_get_filename (this_element))) ++ { ++ non_fatal (_("illegal pathname found in archive member: %s"), ++ bfd_get_filename (this_element)); ++ status = 1; ++ goto cleanup_and_exit; ++ } ++ + /* Create an output file for this member. */ + output_name = concat (dir, "/", + bfd_get_filename (this_element), (char *) 0); +@@ -2215,8 +2225,12 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + { + output_name = make_tempdir (output_name); + if (output_name == NULL) +- fatal (_("cannot create tempdir for archive copying (error: %s)"), +- strerror (errno)); ++ { ++ non_fatal (_("cannot create tempdir for archive copying (error: %s)"), ++ strerror (errno)); ++ status = 1; ++ goto cleanup_and_exit; ++ } + + l = (struct name_list *) xmalloc (sizeof (struct name_list)); + l->name = output_name; +@@ -2258,7 +2272,7 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + { + bfd_nonfatal_message (output_name, NULL, NULL, NULL); + status = 1; +- return; ++ goto cleanup_and_exit; + } + + if (ok_object) +@@ -2319,7 +2333,6 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + { + status = 1; + bfd_nonfatal_message (filename, NULL, NULL, NULL); +- return; + } + + filename = bfd_get_filename (ibfd); +@@ -2327,9 +2340,9 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + { + status = 1; + bfd_nonfatal_message (filename, NULL, NULL, NULL); +- return; + } + ++ cleanup_and_exit: + /* Delete all the files that we opened. */ + for (l = list; l != NULL; l = l->next) + { diff --git a/source/devel/binutils/CVE-2014-8738.patch b/source/devel/binutils/CVE-2014-8738.patch new file mode 100644 index 0000000..4c77bd8 --- /dev/null +++ b/source/devel/binutils/CVE-2014-8738.patch @@ -0,0 +1,49 @@ +From bb0d867169d7e9743d229804106a8fbcab7f3b3f Mon Sep 17 00:00:00 2001 +From: Nick Clifton <[email protected]> +Date: Tue, 4 Nov 2014 13:15:37 +0000 +Subject: [PATCH] Fix a seg-fault triggered by reading a mal-formed archive. + + PR binutils/17533 + * archive.c (_bfd_slurp_extended_name_table): Handle archives with + corrupt extended name tables. + +[Ubuntu note: patch differs from upstream commit in that it drops the +changelog entry and cosmetic changes to reduce patch conflicts. + -- sbeattie] + +CVE-2014-8738 +--- + bfd/archive.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +Index: b/bfd/archive.c +=================================================================== +--- a/bfd/archive.c ++++ b/bfd/archive.c +@@ -1292,6 +1292,9 @@ _bfd_slurp_extended_name_table (bfd *abf + amt = namedata->parsed_size; + if (amt + 1 == 0) + goto byebye; ++ /* PR binutils/17533: A corrupt archive can contain an invalid size. */ ++ if (amt > (bfd_size_type) bfd_get_size (abfd)) ++ goto byebye; + + bfd_ardata (abfd)->extended_names_size = amt; + bfd_ardata (abfd)->extended_names = (char *) bfd_zalloc (abfd, amt + 1); +@@ -1299,6 +1302,8 @@ _bfd_slurp_extended_name_table (bfd *abf + { + byebye: + free (namedata); ++ bfd_ardata (abfd)->extended_names = NULL; ++ bfd_ardata (abfd)->extended_names_size = 0; + return FALSE; + } + +@@ -1307,7 +1312,6 @@ _bfd_slurp_extended_name_table (bfd *abf + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_malformed_archive); + bfd_release (abfd, (bfd_ardata (abfd)->extended_names)); +- bfd_ardata (abfd)->extended_names = NULL; + goto byebye; + } + diff --git a/source/devel/binutils/FrugalBuild b/source/devel/binutils/FrugalBuild index f130c7e..9982b60 100644 --- a/source/devel/binutils/FrugalBuild +++ b/source/devel/binutils/FrugalBuild @@ -3,7 +3,7 @@ pkgname=binutils pkgver=2.24 -pkgrel=4 +pkgrel=5rigel1 pkgdesc="A set of programs to assemble and manipulate binary and object files" url="http://www.gnu.org/software/binutils/" depends=('bash' 'glibc>=2.8-2') @@ -13,6 +13,14 @@ Fup2gnubz2 source=(http://ftp.gnu.org/gnu/$pkgname/$pkgname-${pkgver}.tar.bz2 bug16467.patch) signatures=($source.sig '') + +# FSA fix *** +source=(${source[@]} CVE-2014-8484.patch CVE-2014-8485.patch CVE-2014-8501.patch + CVE-2014-8502.patch CVE-2014-8503.patch CVE-2014-8504.patch + CVE-2014-8737.patch CVE-2014-8738.patch) +signatures=(${signatures[@]} '' '' '' '' '' '' '' '') +# *********** + build() { Fcd _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
