From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D97073858C53; Thu, 18 Jan 2024 04:06:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D97073858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1705550778; bh=5glvSMRuNlan9dKgo8YCXSV6TJjqf5ojBOHJA0ahjkU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lQmhC1F09CYyXhQ4puf6mAftNAyXWNgd/TePMUWbb5L0Ios3UHJvZHCm1nDl0ZtOr W7YkODbZtnTTxyujpwJkkIGrF+TM/bpKwNXgDE2R5209nZ/kdnL6wE0O21BCHmWrce MrgENG9cZJQtQMXTXKbu4ORh9kOrYBRUgRNcrOC0= From: "bgray at linux dot ibm.com" To: gdb-prs@sourceware.org Subject: [Bug shlibs/30663] Segfault when reading malformed PT_INTERP header Date: Thu, 18 Jan 2024 04:06:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: shlibs X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bgray at linux dot ibm.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: cc Message-ID: In-Reply-To: References: 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30663 Benjamin Gray changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bgray at linux dot ibm.com --- Comment #1 from Benjamin Gray --- Ran into this myself and came here to report it. My binary has a `.interp` section, but it has size 0. The following section in gdb/solib-svr4.c enable_break() std::optional interp_name_holder =3D find_program_interpreter (); if (interp_name_holder) { const char *interp_name =3D (const char *) interp_name_holder->data= (); Only checks that a vector is present, not that it has allocated anything. So interp_name is possibly a null pointer. This is propagated down the chain solib_bfd_open() solib_find() solib_find_1() xstrdup() which ultimately segfaults on the null pointer. find_program_interpreter() itself is correctly locating the zero sized `.interp` section, creating a gdb::byte_vector with size 0. This wraps the std::vector type, which avoids an allocation for zero vectors. The bfd_get_section_contents() call trivially returns true because it's 'found'= the contents of this zero sized section, so never touches the data buffer.=20 (actually, it _might_ call memset() on the buffer, which is undefined behav= iour as far as I can tell after a quick search). --=20 You are receiving this mail because: You are on the CC list for the bug.=