From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114183 invoked by alias); 18 Jan 2019 11:17:11 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 114088 invoked by uid 48); 18 Jan 2019 11:17:05 -0000 From: "wcventure at 126 dot com" To: elfutils-devel@sourceware.org Subject: [Bug backends/24102] New: A Heap-buffer-overflow problem was discovered in the function read_srclines in dwarf_getsrclines.c in libdw Date: Fri, 18 Jan 2019 11:17:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: backends X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: wcventure at 126 dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2019-q1/txt/msg00053.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D24102 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=3D11542&action=3Ded= it POC1 Hi,=20 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 E= LF input can cause segment faults and I have confirmed them with address sanit= izer too. Here are the POC files. Please use "./eu-nm -C $POC" to reproduce the error. $git log > commit e65d91d21cb09d83b001fef9435e576ba447db32 > Author: Mark Wielaard > Date: Wed Jan 16 12:25:57 2019 +0100 >=20 > libelf: Correct overflow check in note_xlate. >=20 > 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 h= eader > size wrong). Replace the wrong constant (8) with a sizeof cvt_Nhdr (1= 2). >=20 > https://sourceware.org/bugzilla/show_bug.cgi?id=3D24084 >=20 > Signed-off-by: Mark Wielaard The ASAN dumps the stack trace as follows: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D17493=3D=3DERROR: 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_getsrc= lines.c:1118 > #2 0x7fa8ef1fdefc in dwarf_getsrclines /elfutils/libdw/dwarf_getsrcli= nes.c:1208 > #3 0x7fa8ef20a146 in dwarf_getsrcfiles /elfutils/libdw/dwarf_getsrcfi= les.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) >=20 > 0x6100000003fc is located 0 bytes to the right of 188-byte region [0x6100= 00000340,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/e= lf_getdata.c:447 >=20 > SUMMARY: AddressSanitizer: heap-buffer-overflow /elfutils/libdw/dwarf_get= srclines.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 > =3D>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=20 > 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 > =3D=3D17493=3D=3DABORTING --=20 You are receiving this mail because: You are on the CC list for the bug.