https://sourceware.org/bugzilla/show_bug.cgi?id=24102
Bug ID: 24102 Summary: A Heap-buffer-overflow problem was discovered in the function read_srclines in dwarf_getsrclines.c in libdw Product: elfutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: backends Assignee: unassigned at sourceware dot org Reporter: wcventure at 126 dot com CC: elfutils-devel at sourceware dot org Target Milestone: --- Created attachment 11542 --> https://sourceware.org/bugzilla/attachment.cgi?id=11542&action=edit POC1 Hi, A Heap-buffer-overflow problem was discovered in the function read_srclines in dwarf_getsrclines.c in libdw, as distributed in ELFutils 0.175. A crafted ELF input can cause segment faults and I have confirmed them with address sanitizer too. Here are the POC files. Please use "./eu-nm -C $POC" to reproduce the error. $git log > commit e65d91d21cb09d83b001fef9435e576ba447db32 > Author: Mark Wielaard <m...@klomp.org> > Date: Wed Jan 16 12:25:57 2019 +0100 > > libelf: Correct overflow check in note_xlate. > > We want to make sure the note_len doesn't overflow and becomes shorter > than the note header. But the namesz and descsz checks got the note header > size wrong). Replace the wrong constant (8) with a sizeof cvt_Nhdr (12). > > https://sourceware.org/bugzilla/show_bug.cgi?id=24084 > > Signed-off-by: Mark Wielaard <m...@klomp.org> The ASAN dumps the stack trace as follows: > ================================================================= > ==17493==ERROR: AddressSanitizer: heap-buffer-overflow on address > 0x6100000003fc at pc 0x7fa8ef1fc077 bp 0x7ffebd930000 sp 0x7ffebd92fff0 > READ of size 1 at 0x6100000003fc thread T0 > #0 0x7fa8ef1fc076 in read_srclines /elfutils/libdw/dwarf_getsrclines.c:474 > #1 0x7fa8ef1fd149 in __libdw_getsrclines > /elfutils/libdw/dwarf_getsrclines.c:1118 > #2 0x7fa8ef1fdefc in dwarf_getsrclines > /elfutils/libdw/dwarf_getsrclines.c:1208 > #3 0x7fa8ef20a146 in dwarf_getsrcfiles > /elfutils/libdw/dwarf_getsrcfiles.c:92 > #4 0x407f71 in get_local_names /elfutils/src/nm.c:644 > #5 0x407f71 in show_symbols /elfutils/src/nm.c:1285 > #6 0x40ef63 in handle_elf /elfutils/src/nm.c:1578 > #7 0x403964 in process_file /elfutils/src/nm.c:374 > #8 0x403964 in main /elfutils/src/nm.c:249 > #9 0x7fa8ee5a282f in __libc_start_main > (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) > #10 0x404608 in _start (/elfutils/build/bin/eu-nm+0x404608) > > 0x6100000003fc is located 0 bytes to the right of 188-byte region > [0x610000000340,0x6100000003fc) > allocated by thread T0 here: > #0 0x7fa8ef682b90 in __interceptor_malloc > (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb90) > #1 0x7fa8eef3a08f in convert_data /elfutils/libelf/elf_getdata.c:157 > #2 0x7fa8eef3a08f in __libelf_set_data_list_rdlock > /elfutils/libelf/elf_getdata.c:447 > > SUMMARY: AddressSanitizer: heap-buffer-overflow > /elfutils/libdw/dwarf_getsrclines.c:474 in read_srclines > Shadow bytes around the buggy address: > 0x0c207fff8020: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00 > 0x0c207fff8030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 0x0c207fff8040: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00 > 0x0c207fff8050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 0x0c207fff8060: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00 > =>0x0c207fff8070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00[04] > 0x0c207fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > 0x0c207fff8090: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > 0x0c207fff80a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > 0x0c207fff80b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > 0x0c207fff80c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > 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 > ==17493==ABORTING -- You are receiving this mail because: You are on the CC list for the bug.