[bison 3.7] Bug Report

Suhwan Song <[email protected]>
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <CACoRL40MoWHa=oLPxg05BPDrSQTP4pcZEZuc=d4EBtBCQk0a5g@mail.gmail.com>
Hi, I'm Suhwan Song from Seoul National University.

I found the use-after-free bug in bison 3.7 which is the latest version.
I attached the poc file and the asan log.

To reproduce the bug
1) Compile the bison with address sanitizer
2) run the bision ($ bison $PoC)

Thanks,
Suhwan.

[image: image.png]
ᐧ
image.png (image/png, 136.8 KB) - not displayed
bug_report.txt (text/plain, 2.6 KB)
==21400==ERROR: AddressSanitizer: heap-use-after-free on address 0x621000002908 at pc 0x55be55dfed00 bp 0x7ffe2e87ab60 sp 0x7ffe2e87ab50
READ of size 8 at 0x621000002908 thread T0
    #0 0x55be55dfecff in _obstack_free lib/obstack.c:273
    #1 0x55be55b96997 in gram_lex /Users/akim/src/gnu/bison/src/scan-gram.l:614
    #2 0x55be55aa48c6 in gram_parse src/parse-gram.c:2067
    #3 0x55be55b15c4e in reader src/reader.c:712
    #4 0x55be558c0dca in main src/main.c:108
    #5 0x7f9d017ebb96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #6 0x55be558c48e9 in _start (/mnt/hda2/suhwan/add_project/final/FINAL_TEST_ZONE/program/bison-3.7/install_dir/bin/bison+0x388e9)

0x621000002908 is located 8 bytes inside of 4064-byte region [0x621000002900,0x6210000038e0)
freed by thread T0 here:
    #0 0x7f9d01c997a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
    #1 0x55be55dfe52a in call_freefun lib/obstack.c:98
    #2 0x55be55dfe52a in _obstack_free lib/obstack.c:274

previously allocated by thread T0 here:
    #0 0x7f9d01c99b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x55be55df3880 in xmalloc lib/xmalloc.c:53

SUMMARY: AddressSanitizer: heap-use-after-free lib/obstack.c:273 in _obstack_free
Shadow bytes around the buggy address:
  0x0c427fff84d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff84e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff84f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff8500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff8510: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c427fff8520: fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c427fff8530: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c427fff8540: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c427fff8550: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c427fff8560: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c427fff8570: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==21400==ABORTING
poc (application/octet-stream, 4.1 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.