From nobody Sat Mar 16 13:18:24 2024 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TxhWk24y7z5DpNX for ; Sat, 16 Mar 2024 13:18:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TxhWj3gg0z3xHg for ; Sat, 16 Mar 2024 13:18:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710595105; a=rsa-sha256; cv=none; b=Kd9y6BlF6OTP8dJNNsLcgu/7eGs7fBENGo1M3QY91t4so1U06TQ8mCjXIclY56AJ1CFjFe cQiCAdAyty0sq8Lr5dN4tOfsPuAKyaVNsK/5PRZdtXmvOzEoJAsF+PV0yR3pf/446eEslQ cIdl06r+55e0+Ksbvtl8qrKaTCD3ra9bAtFpsbh/TTRgTFDmB+ljGEJHejdC1eh9+nVfWI CVwt3rxEfItyz09CneFABF/UYRRkvLLlHOqfZo2iecEzR/qHgXFl3dD+w3Co3D5ViJzPpY SESy6Z1hGzQ25KwoT0DSkhI5bFYpcwDpIenrsyHenm97vS9AnFCxZSbYHXRMZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710595105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oIMV4PXi31uSLAZjm/mYK4SY58OQb1gN7QfD1kN3InI=; b=HEEC43WA9pThudJEaDynKOPSNR6bfyFp5MZLpjjqbjGHf7Pgmpjkjhqsq2faQKooh849mP kN6FrLTKgTdJUNK67cE1Wy4CIv/2gM4bJq1XCjDE2Y50R12dmceYkazX8kow7OE1sPZ2KX 3VLaZEoQSWRRVetFocfld5NPQfpdxY0x4R5G4w0Fsmu3ERDP8QDn8H6C1l0r5eDMsFqLvn Kz1wa1gBjnIAgCVnm59snZiBwkaPgoGlX2/PD/E+fPbenkBJrz3fBqy6jbUvYtGBlN7yWe 2MzD3ao1p89sb798zXqI5WwjMTwMraBuNo8QyNrQoG8P5tPEJpUqDxxi0wDXyQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TxhWj36jQzwbL for ; Sat, 16 Mar 2024 13:18:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 42GDIP3W003838 for ; Sat, 16 Mar 2024 13:18:25 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 42GDIPUb003836 for bugs@FreeBSD.org; Sat, 16 Mar 2024 13:18:25 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 277736] llvm-objdump can crash due to ELFFile::dynamicEntries() not checking p_offset Date: Sat, 16 Mar 2024 13:18:24 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: rtm@lcs.mit.edu X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277736 Bug ID: 277736 Summary: llvm-objdump can crash due to ELFFile::dynamicEntries() not checking p_offset Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu Created attachment 249216 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D249216&action= =3Dedit a corrupt ELF file that causes llvm-objdump to crash This line in llvm-project/llvm/lib/Object/ELF.cpp dynamicEntries() forms a pointer from p_offset without checking whether it's too large: Dyn =3D ArrayRef(reinterpret_cast(base() + Phdr.p_of= fset), Phdr.p_filesz / sizeof(Elf_Dyn)); As a result a corrupt ELF file can cause objdump to crash. I've attached a demo. # uname -a FreeBSD stock14 15.0-CURRENT FreeBSD 15.0-CURRENT #19 main-n268743-a58813fd701e: Sat Mar 9 07:18:21 AST 2024=20=20=20=20 root@stock14:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 # objdump --version LLVM (http://llvm.org/): LLVM version 17.0.6 Optimized build with assertions. ... # objdump -p ldd1b.exe=20 ... PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include = the crash backtrace. Stack dump: 0. Program arguments: objdump -p ldd1b.exe #0 0x0000000001230c41 PrintStackTrace /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:602:13 #1 0x000000000122f0b5 RunSignalHandlers /usr/src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:105:18 #2 0x0000000001231365 SignalHandler /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3 #3 0x00000008249cf5ff handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0= :3 #4 0x00000008249cebbb thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:244:1 #5 0x000000082270d2d3 ([vdso]+0x2d3) #6 0x0000000000f96641 dynamicEntries /usr/src/contrib/llvm-project/llvm/lib/Object/ELF.cpp:590:24 #7 0x0000000000df2268 operator bool /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:559:17 #8 0x0000000000df2268 printDynamicSection /usr/src/contrib/llvm-project/llvm/tools/llvm-objdump/ELFDump.cpp:205:8 #9 0x0000000000df2268 printPrivateHeaders /usr/src/contrib/llvm-project/llvm/tools/llvm-objdump/ELFDump.cpp:431:3 #10 0x0000000000e6a13c dumpObject /usr/src/contrib/llvm-project/llvm/tools/llvm-objdump/llvm-objdump.cpp:2815= :7 #11 0x0000000000e654b0 dumpInput /usr/src/contrib/llvm-project/llvm/tools/llvm-objdump/llvm-objdump.cpp:0:5 #12 0x0000000000e654b0 for_each, std::__1::allocator > *>, void (*)(llvm::StringRef)> /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/__algorithm/for_each.h:= 26:5 #13 0x0000000000e654b0 for_each, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > > &, void (*)(llvm::StringRef)> /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/STLExtras.h:1731:10 #14 0x0000000000e654b0 main /usr/src/contrib/llvm-project/llvm/tools/llvm-objdump/llvm-objdump.cpp:3248= :3 #15 0x0000000828a2d0aa __libc_start1 /usr/src/lib/libc/csu/libc_start1.c:15= 7:2 Bus error (core dumped) --=20 You are receiving this mail because: You are the assignee for the bug.=