From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 7099C3858C01 for ; Wed, 1 Nov 2023 23:32:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7099C3858C01 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7099C3858C01 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698881545; cv=none; b=oCDPPJojf/ZZIsbG+cBxbcfJdrFrm+cf3de7uF9myGb7o4TJtnOknTRdeVvdR+W0kAxf1iFR2UZDqQuLC/buBnT/YXShwedTjKntw4/PUpf0BdB1eeAUhXTnF291tz+/vVx5qsn9DnlIVK3TNyDjag+XbUMpdaLSYFO126ft56o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698881545; c=relaxed/simple; bh=QFDI/9o/Wg8tQpUG9aHzq/kcpgoSzmY0xc9dnj77V3Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=K7Y1lrlx34pqydluYPYo0N38F2BcO9o1eEcKNBO/O+BHqI4p+/R48c0EMw6MAOvvLi4ky67KHHsC5FQnODkrmrizz+K4F2XIgGSNszWeLXIc7eAcXD8Gfyl88BLwJdcD/tFEgDVXcq0agnJ9NzG3xNaqZ07ncXr/ziPx8gp0u40= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698881535; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gqBl1vsuUp4XsF07o5Vp0nNAnq0KcG3juTVTU+EBfOQ=; b=PBUlbOTCtILdaakgsPAdU86nOENJU0MounK+loHMf+N97EG4hrvOxoaoIaStzVfmcB2b8w ESA1nM+9GVJW9tVMc9RWdFSqfalAsr/JRDpgJbodW6sE4vTZ91qYGzw8nM6R6aKI1mjUj6 R/SbtKX+77vjldnsPAWWjV2SK5c5pwQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-TiWrw0ajO2q2Qhjr-7mKYA-1; Wed, 01 Nov 2023 19:32:13 -0400 X-MC-Unique: TiWrw0ajO2q2Qhjr-7mKYA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48EF51C294AA for ; Wed, 1 Nov 2023 23:32:13 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.32.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4A3B2026D4C; Wed, 1 Nov 2023 23:32:12 +0000 (UTC) From: Aaron Merey To: elfutils-devel@sourceware.org Cc: Aaron Merey Subject: [COMMITTED][Bug libdw/30980] dwfl_offline_section_address: replace asserts with early return Date: Wed, 1 Nov 2023 19:32:08 -0400 Message-ID: <20231101233208.271595-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: dwfl_offline_section_address asserts that the current module is ET_REL. A possibly corrupt .gnu_debuglink can cause an abort by calling dwfl_offline_section_address on an ET_DYN module. Prevent this abort and similar ones by replacing dwfl_offline_section_address initial asserts with an early return. https://sourceware.org/bugzilla/show_bug.cgi?id=30980 Signed-off-by: Aaron Merey --- libdwfl/offline.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libdwfl/offline.c b/libdwfl/offline.c index e090b42b..52539fe3 100644 --- a/libdwfl/offline.c +++ b/libdwfl/offline.c @@ -50,10 +50,11 @@ dwfl_offline_section_address (Dwfl_Module *mod, const GElf_Shdr *shdr __attribute__ ((unused)), Dwarf_Addr *addr) { - assert (mod->e_type == ET_REL); - assert (shdr->sh_addr == 0); - assert (shdr->sh_flags & SHF_ALLOC); - assert (shndx != 0); + if (mod->e_type != ET_REL + || shdr->sh_addr != 0 + || !(shdr->sh_flags & SHF_ALLOC) + || shndx == 0) + return -1; if (mod->debug.elf == NULL) /* We are only here because sh_addr is zero even though layout is complete. -- 2.41.0