From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28151 invoked by alias); 17 Oct 2018 08:37:01 -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 26470 invoked by uid 48); 17 Oct 2018 08:36:51 -0000 From: "wcventure at 126 dot com" To: elfutils-devel@sourceware.org Subject: [Bug general/23786] New: Divide-by-zero Problem in function arlib_add_symbols() in arlib.c in elfutils-0.174 Date: Wed, 17 Oct 2018 08:37:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: general X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: critical 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: 2018-q4/txt/msg00044.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D23786 Bug ID: 23786 Summary: Divide-by-zero Problem in function arlib_add_symbols() in arlib.c in elfutils-0.174 Product: elfutils Version: unspecified Status: UNCONFIRMED Severity: critical Priority: P2 Component: general Assignee: unassigned at sourceware dot org Reporter: wcventure at 126 dot com CC: elfutils-devel at sourceware dot org Target Milestone: --- Hi, I found some floating point exception in function arlib_add_symbols() in arlib.c of the latest elfutils-0.174 code base. I have confirmed them with = GDB and Address Sanitizer. Here are the POC files. Please use " ./eu-ranlib $POC " to reproduce this b= ug. I'll also show you the debugging process. It seems that this is caused by t= he divide-by-zero.=20 In arlib.c:255, there exist a division calculation: > int nsyms =3D shdr->sh_size / shdr->sh_entsize; I can provide you some testcases to make shdr->sh_entsize =3D 0. And you ca= n use the testcases to reproduce the bug. Divide by zero is bad. We need to make a check before doing division calculation. --- Comment #1 from wcventure --- Created attachment 11336 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D11336&action=3Ded= it POC1 I have also confirmed them with Address Sanitizer. The ASAN dumps the stack trace as follows: ASAN:DEADLYSIGNAL =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=3D2496=3D=3DERROR: AddressSanitizer: FPE on unknown address 0x000000406= 5d8 (pc 0x0000004065d8 bp 0x7ffd4c109620 sp 0x7ffd4c109550 T0) #0 0x4065d7 in arlib_add_symbols /media/hjwang/01D3344861A8D2E0/wcventure/Project/elfutils/src/arlib.c:255 #1 0x4029c5 in handle_file /media/hjwang/01D3344861A8D2E0/wcventure/Project/elfutils/src/ranlib.c:193 #2 0x4029c5 in main /media/hjwang/01D3344861A8D2E0/wcventure/Project/elfutils/src/ranlib.c:110 #3 0x7fc97b51982f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) #4 0x403d28 in _start (/media/hjwang/01D3344861A8D2E0/wcventure/Project/elfutils/build/bin/eu-ran= lib+0x403d28) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: FPE /media/hjwang/01D3344861A8D2E0/wcventure/Project/elfutils/src/arlib.c:255 in arlib_add_symbols =3D=3D2496=3D=3DABORTING Aborted --=20 You are receiving this mail because: You are on the CC list for the bug.