Created attachment 10021 [details] Input Dear All, This bug was found with AFLGo, a directed version of AFL/AFLFast. Thanks also to Marcel Böhme and Van-Thuan Pham. This bug was found on Ubuntu 14.04 64-bit & binutils was checked out from main repository at git://sourceware.org/git/binutils-gdb.git. Its commit is a49abe0bb18e04d3a4b692995fcfae70cd470775 (Tue Apr 25 00:00:36 2017). binutils was built with ASAN using gcc-6.2 and clang-3.4. The configure command was: CC=clang CFLAGS="-DFORTIFY_SOURCE=2 -fstack-protector-all -fsanitize=undefined,address -fno-omit-frame-pointer -g -Wno-error" ../configure --disable-shared --disable-gdb --disable-libdecnumber --disable-readline --disable-sim To reproduce: Download the attached file - bug_8 objdump -W bug_8 ASAN says: ==21468==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x611000009dbf at pc 0x000001112c62 bp 0x7ffff9c91060 sp 0x7ffff9c91058 READ of size 1 at 0x611000009dbf thread T0 #0 0x1112c61 in bfd_perform_relocation /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/reloc.c:885:11 #1 0x1120f83 in bfd_generic_get_relocated_section_contents /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/reloc.c:8170:10 #2 0x763254 in bfd_get_relocated_section_contents /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/bfd.c:1624:10 #3 0x7b8969 in bfd_simple_get_relocated_section_contents /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/simple.c:264:14 #4 0x4f51b4 in load_specific_debug_section /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:2482:13 #5 0x508341 in dump_dwarf_section /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:2620:6 #6 0x7b437c in bfd_map_over_sections /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/section.c:1395:5 #7 0x500415 in dump_dwarf /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:2689:3 #8 0x4fac4b in dump_bfd /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:3527:5 #9 0x4f9d41 in display_object_bfd /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:3594:7 #10 0x4f9c1a in display_any_bfd /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:3683:5 #11 0x4f91f7 in display_file /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:3704:3 #12 0x4f8344 in main /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:4006:6 #13 0x7f922c820f44 in __libc_start_main /build/eglibc-MjiXCM/eglibc-2.19/csu/libc-start.c:287 #14 0x41b5f5 in _start (/home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/objdump+0x41b5f5) SUMMARY: AddressSanitizer: heap-buffer-overflow /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/reloc.c:885:11 in bfd_perform_relocations VALGRIND says: ==153426== Invalid read of size 1 ==153426== at 0x4D1D15: bfd_perform_relocation (reloc.c:885) ==153426== by 0x4D29AA: bfd_generic_get_relocated_section_contents (reloc.c:8170) ==153426== by 0x44FDCB: bfd_simple_get_relocated_section_contents (simple.c:264) ==153426== by 0x40AD53: load_specific_debug_section (objdump.c:2482) ==153426== by 0x40AF58: dump_dwarf_section (objdump.c:2620) ==153426== by 0x44F7FB: bfd_map_over_sections (section.c:1395) ==153426== by 0x406E13: dump_dwarf (objdump.c:2689) ==153426== by 0x40812D: dump_bfd (objdump.c:3527) ==153426== by 0x4089BF: display_object_bfd (objdump.c:3594) ==153426== by 0x4089BF: display_any_bfd (objdump.c:3683) ==153426== by 0x40ABC3: display_file (objdump.c:3704) ==153426== by 0x404CDD: main (objdump.c:4006) ==153426== Address 0x541f18f is 1 bytes before a block of size 220 alloc'd ==153426== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==153426== by 0x44C9FD: bfd_malloc (libbfd.c:184) ==153426== by 0x44AD97: bfd_get_full_section_contents (compress.c:248) ==153426== by 0x40AD15: load_specific_debug_section (objdump.c:2468) ==153426== by 0x40AF58: dump_dwarf_section (objdump.c:2620) ==153426== by 0x44F7FB: bfd_map_over_sections (section.c:1395) ==153426== by 0x406E13: dump_dwarf (objdump.c:2689) ==153426== by 0x40812D: dump_bfd (objdump.c:3527) ==153426== by 0x4089BF: display_object_bfd (objdump.c:3594) ==153426== by 0x4089BF: display_any_bfd (objdump.c:3683) ==153426== by 0x40ABC3: display_file (objdump.c:3704) ==153426== by 0x404CDD: main (objdump.c:4006) ==153426== ==153426== Invalid write of size 1 ==153426== at 0x4D1D2F: bfd_perform_relocation (reloc.c:886) ==153426== by 0x4D29AA: bfd_generic_get_relocated_section_contents (reloc.c:8170) ==153426== by 0x44FDCB: bfd_simple_get_relocated_section_contents (simple.c:264) ==153426== by 0x40AD53: load_specific_debug_section (objdump.c:2482) ==153426== by 0x40AF58: dump_dwarf_section (objdump.c:2620) ==153426== by 0x44F7FB: bfd_map_over_sections (section.c:1395) ==153426== by 0x406E13: dump_dwarf (objdump.c:2689) ==153426== by 0x40812D: dump_bfd (objdump.c:3527) ==153426== by 0x4089BF: display_object_bfd (objdump.c:3594) ==153426== by 0x4089BF: display_any_bfd (objdump.c:3683) ==153426== by 0x40ABC3: display_file (objdump.c:3704) ==153426== by 0x404CDD: main (objdump.c:4006) ==153426== Address 0x541f18f is 1 bytes before a block of size 220 alloc'd ==153426== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==153426== by 0x44C9FD: bfd_malloc (libbfd.c:184) ==153426== by 0x44AD97: bfd_get_full_section_contents (compress.c:248) ==153426== by 0x40AD15: load_specific_debug_section (objdump.c:2468) ==153426== by 0x40AF58: dump_dwarf_section (objdump.c:2620) ==153426== by 0x44F7FB: bfd_map_over_sections (section.c:1395) ==153426== by 0x406E13: dump_dwarf (objdump.c:2689) ==153426== by 0x40812D: dump_bfd (objdump.c:3527) ==153426== by 0x4089BF: display_object_bfd (objdump.c:3594) ==153426== by 0x4089BF: display_any_bfd (objdump.c:3683) ==153426== by 0x40ABC3: display_file (objdump.c:3704) ==153426== by 0x404CDD: main (objdump.c:4006) ==153426==
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=04b31182bf3f8a1a76e995bdfaaaab4c009b9cb2 commit 04b31182bf3f8a1a76e995bdfaaaab4c009b9cb2 Author: Nick Clifton <nickc@redhat.com> Date: Wed Apr 26 16:30:22 2017 +0100 Fix a seg-fault when processing a corrupt binary containing reloc(s) with negative addresses. PR binutils/21434 * reloc.c (bfd_perform_relocation): Check for a negative address in the reloc.
Hi Manh-Dung, Thanks for reporting this problem. I have checked in a patch to fix the bug - we were not checking for relocs with small negative addresses - and the problem should now be fixed. Cheers Nick
Thanks Nick. This is CVE-2017-8397.