This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/binutils-2_29-branch] x86: Guard against corrupted PLT


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=56933f9e3e90eebf1018ed7417d6c1184b91db6b

commit 56933f9e3e90eebf1018ed7417d6c1184b91db6b
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Sep 22 14:15:40 2017 -0700

    x86: Guard against corrupted PLT
    
    There should be only one entry in PLT for a given symbol.  Set howto to
    NULL after processing a PLT entry to guard against corrupted PLT so that
    the duplicated PLT entries are skipped.
    
    	PR binutils/22170
    	 * elf32-i386.c (elf_i386_get_synthetic_symtab): Guard against
    	 corrupted PLT.
    	 * elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
    
    (cherry picked from commit 61e3bf5f83f7e505b6bc51ef65426e5b31e6e360)

Diff:
---
 bfd/ChangeLog      | 7 +++++++
 bfd/elf32-i386.c   | 4 ++++
 bfd/elf64-x86-64.c | 4 ++++
 3 files changed, 15 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 31e2a7f..7091d75 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,12 @@
 2017-09-22  H.J. Lu  <hongjiu.lu@intel.com>
 
+	PR binutils/22170
+	* elf32-i386.c (elf_i386_get_synthetic_symtab): Guard against
+	corrupted PLT.
+	* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
+
+2017-09-22  H.J. Lu  <hongjiu.lu@intel.com>
+
 	PR binutils/22163
 	* elf32-i386.c (elf_i386_get_synthetic_symtab): Also return -1
 	if bfd_canonicalize_dynamic_reloc returns 0.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 9dc2d25..ba50c93 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -6616,6 +6616,10 @@ bad_return:
 		  size += sizeof ("+0x") - 1 + 8;
 		n++;
 		s++;
+		/* There should be only one entry in PLT for a given
+		   symbol.  Set howto to NULL after processing a PLT
+		   entry to guard against corrupted PLT.  */
+		p->howto = NULL;
 	      }
 	    offset += plt_entry_size;
 	  }
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 558db98..d9225ad 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -6970,6 +6970,10 @@ bad_return:
 		  size += sizeof ("+0x") - 1 + 8 + 8 * ABI_64_P (abfd);
 		n++;
 		s++;
+		/* There should be only one entry in PLT for a given
+		   symbol.  Set howto to NULL after processing a PLT
+		   entry to guard against corrupted PLT.  */
+		p->howto = NULL;
 	      }
 	    offset += plt_entry_size;
 	  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]