From f62ff52c8954878b15fbd2ea95eb6c4ed46aca70 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Aug 28 2018 12:05:02 +0000 Subject: Detect and report corrupt symbol version information. Relates: #1599521 --- diff --git a/binutils-detect-corrupt-sym-version-info.patch b/binutils-detect-corrupt-sym-version-info.patch new file mode 100644 index 0000000..dc7cf17 --- /dev/null +++ b/binutils-detect-corrupt-sym-version-info.patch @@ -0,0 +1,52 @@ +diff -rup binutils,orig/bfd/elf.c binutils-2.31.1/bfd/elf.c +--- binutils,orig/bfd/elf.c 2018-08-28 12:38:29.987511521 +0100 ++++ binutils-2.31.1/bfd/elf.c 2018-08-28 12:39:35.010036349 +0100 +@@ -1877,7 +1877,7 @@ _bfd_elf_get_symbol_version_string (bfd + { + Elf_Internal_Verneed *t; + +- version_string = ""; ++ version_string = _(""); + for (t = elf_tdata (abfd)->verref; + t != NULL; + t = t->vn_nextref) +diff -rup binutils,orig/binutils/readelf.c binutils-2.31.1/binutils/readelf.c +--- binutils,orig/binutils/readelf.c 2018-08-28 12:38:30.552507392 +0100 ++++ binutils-2.31.1/binutils/readelf.c 2018-08-28 12:42:04.625942967 +0100 +@@ -11263,6 +11263,7 @@ get_symbol_version_string (Filedata * + unsigned char data[2]; + unsigned short vers_data; + unsigned long offset; ++ unsigned short max_vd_ndx; + + if (!is_dynsym + || version_info[DT_VERSIONTAGIDX (DT_VERSYM)] == 0) +@@ -11280,6 +11281,8 @@ get_symbol_version_string (Filedata * + if ((vers_data & VERSYM_HIDDEN) == 0 && vers_data == 0) + return NULL; + ++ max_vd_ndx = 0; ++ + /* Usually we'd only see verdef for defined symbols, and verneed for + undefined symbols. However, symbols defined by the linker in + .dynbss for variables copied from a shared library in order to +@@ -11322,6 +11325,9 @@ get_symbol_version_string (Filedata * + ivd.vd_flags = BYTE_GET (evd.vd_flags); + } + ++ if ((ivd.vd_ndx & VERSYM_VERSION) > max_vd_ndx) ++ max_vd_ndx = ivd.vd_ndx & VERSYM_VERSION; ++ + off += ivd.vd_next; + } + while (ivd.vd_ndx != (vers_data & VERSYM_VERSION) && ivd.vd_next != 0); +@@ -11413,6 +11419,9 @@ get_symbol_version_string (Filedata * + return (ivna.vna_name < strtab_size + ? strtab + ivna.vna_name : _("")); + } ++ else if ((max_vd_ndx || (vers_data & VERSYM_VERSION) != 1) ++ && (vers_data & VERSYM_VERSION) > max_vd_ndx) ++ return _(""); + } + return NULL; + } diff --git a/binutils.spec b/binutils.spec index 4bcd5af..850ff06 100644 --- a/binutils.spec +++ b/binutils.spec @@ -69,7 +69,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.31.1 -Release: 11%{?dist} +Release: 12%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -177,6 +177,10 @@ Patch14: binutils-merge-attribute-sections.patch # Lifetime: Fixed in 2.32 Patch15: binutils-note-merge-improvements.patch +# Purpose: Detect and report corrupt symbol version information. +# Lifetime: Fixed in 2.32 +Patch16: binutils-detect-corrupt-sym-version-info.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -316,6 +320,7 @@ using libelf instead of BFD. %patch13 -p1 %patch14 -p1 %patch15 -p1 +%patch16 -p1 # We cannot run autotools as there is an exact requirement of autoconf-2.59. @@ -723,6 +728,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Tue Aug 28 2018 Nick Clifton - 2.31.1-12 +- Detect and report corrupt symbol version information. (#1599521) + * Tue Aug 14 2018 Nick Clifton - 2.31.1-11 - Remove the version information from a dynamic symbol that is being overridden. (#1614920)