diff options
author | Alan Modra <amodra@gmail.com> | 2018-10-13 22:03:02 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-10-13 23:54:33 +1030 |
commit | 0930cb3021b8078b34cf216e79eb8608d017864f (patch) | |
tree | c5368b36cb84da2d40b57d14e28432773ef161c9 /bfd/elf32-nds32.c | |
parent | 2bf2bf23da5237f465fdbb759657aeb7825a08a3 (diff) | |
download | binutils-0930cb3021b8078b34cf216e79eb8608d017864f.zip binutils-0930cb3021b8078b34cf216e79eb8608d017864f.tar.gz binutils-0930cb3021b8078b34cf216e79eb8608d017864f.tar.bz2 |
_bfd_clear_contents bounds checking
This PR shows a fuzzed binary triggering a segfault via a bad
relocation in .debug_line. It turns out that unlike normal
relocations applied to a section, the linker applies those with
symbols from discarded sections via _bfd_clear_contents without
checking that the relocation is within the section bounds. The same
thing now happens when reading debug sections since commit
a4cd947aca23, the PR23425 fix.
PR 23770
PR 23425
* reloc.c (_bfd_clear_contents): Replace "location" param with
"buf" and "off". Bounds check "off". Return status.
* cofflink.c (_bfd_coff_generic_relocate_section): Update
_bfd_clear_contents call.
* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Likewise.
* elf32-arc.c (elf_arc_relocate_section): Likewise.
* elf32-i386.c (elf_i386_relocate_section): Likewise.
* elf32-metag.c (metag_final_link_relocate): Likewise.
* elf32-nds32.c (nds32_elf_get_relocated_section_contents): Likewise.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
* elf32-visium.c (visium_elf_relocate_section): Likewise.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* elf64-x86-64.c *(elf_x86_64_relocate_section): Likewise.
* libbfd-in.h (_bfd_clear_contents): Update prototype.
* libbfd.h: Regenerate.
Diffstat (limited to 'bfd/elf32-nds32.c')
-rw-r--r-- | bfd/elf32-nds32.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 0d86e5b..184cf32 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -13217,14 +13217,14 @@ nds32_elf_get_relocated_section_contents (bfd *abfd, symbol = *(*parent)->sym_ptr_ptr; if (symbol->section && discarded_section (symbol->section)) { - bfd_byte *p; + bfd_vma off; static reloc_howto_type none_howto = HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, "unused", FALSE, 0, 0, FALSE); - p = data + (*parent)->address * bfd_octets_per_byte (input_bfd); - _bfd_clear_contents ((*parent)->howto, input_bfd, input_section, - p); + off = (*parent)->address * bfd_octets_per_byte (input_bfd); + _bfd_clear_contents ((*parent)->howto, input_bfd, + input_section, data, off); (*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; (*parent)->addend = 0; (*parent)->howto = &none_howto; |