Bug 21595 - global-buffer-overflow in aarch64_ext_ldst_reglist
Summary: global-buffer-overflow in aarch64_ext_ldst_reglist
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.29
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-14 12:38 UTC by Alexandre Adamski
Modified: 2017-06-15 12:30 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
testcase (72 bytes, application/octet-stream)
2017-06-14 12:38 UTC, Alexandre Adamski
Details
report (1.13 KB, text/plain)
2017-06-14 12:38 UTC, Alexandre Adamski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre Adamski 2017-06-14 12:38:19 UTC
Hello there,

I have been fuzzing objdump with American Fuzzy Lop and AddressSanitizer.

Please find attached the minimized file causing the issue ("Input") and the ASAN report log ("Output"). Below is the reduced stacktrace with links to the corresponding source lines on a GitHub mirror.

The command used was `objdump -D <file>`. The compilation flags used were `-g -O2 -fno-omit-frame-pointer -fsanitize=address -fno-sanitize-recover=undefined`. The configuration settings used were `--enable-targets=all --disable-shared`.

Let me know if there is any additional information I can provide.

--

Input: 3ade4a4333249762a9df82c47f3c111a.65dbcbffa0f6467be847e1372688623b.min
Output: 3ade4a4333249762a9df82c47f3c111a.65dbcbffa0f6467be847e1372688623b.txt

Error in "aarch64_ext_ldst_reglist": global-buffer-overflow
  in aarch64_ext_ldst_reglist at opcodes/aarch64-dis.c:412
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/opcodes/aarch64-dis.c#L412)
  in aarch64_opcode_decode at opcodes/aarch64-dis.c:2739
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/opcodes/aarch64-dis.c#L2739)
  in aarch64_decode_insn at opcodes/aarch64-dis.c:2831
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/opcodes/aarch64-dis.c#L2831)
  in print_insn_aarch64_word at opcodes/aarch64-dis.c:2973
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/opcodes/aarch64-dis.c#L2973)
  in print_insn_aarch64 at opcodes/aarch64-dis.c:3209
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/opcodes/aarch64-dis.c#L3209)
  in disassemble_bytes at binutils/objdump.c:1864
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/binutils/objdump.c#L1864)
  in disassemble_section at binutils/objdump.c:2309
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/binutils/objdump.c#L2309)
  in bfd_map_over_sections at bfd/section.c:1395
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/bfd/section.c#L1395)
  in disassemble_data at binutils/objdump.c:2445
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/binutils/objdump.c#L2445)
  in dump_bfd at binutils/objdump.c:3547
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/binutils/objdump.c#L3547)
  in display_file at binutils/objdump.c:3714
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/binutils/objdump.c#L3714)
  in main at binutils/objdump.c:4016
    (see https://github.com/bminor/binutils-gdb/blob/561bf3e950e410fbcac06523d43039f1f58150ca/binutils/objdump.c#L4016)
Comment 1 Alexandre Adamski 2017-06-14 12:38:34 UTC
Created attachment 10136 [details]
testcase
Comment 2 Alexandre Adamski 2017-06-14 12:38:51 UTC
Created attachment 10137 [details]
report
Comment 3 cvs-commit@gcc.gnu.org 2017-06-15 12:27:54 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

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

commit cd3ea7c69acc5045eb28f9bf80d923116e15e4f5
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Jun 15 13:26:54 2017 +0100

    Prevent address violation problem when disassembling corrupt aarch64 binary.
    
    	PR binutils/21595
    	* aarch64-dis.c (aarch64_ext_ldst_reglist): Check for an out of
    	range value.
Comment 4 Nick Clifton 2017-06-15 12:30:00 UTC
Hi Aadamski,

  Thanks for reporting this bug.  This was a simple case of a missing range
  check when decoding the LDST instruction, so I have checked in a small
  patch to fix it.

Cheers
  Nick