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 16C3038C2658 for ; Mon, 19 Dec 2022 11:13:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 16C3038C2658 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671448400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=ld4DVRt1JN2SltqKTwBmpAQ8RCTqLeCocgcIq+9gkdY=; b=B8jG/Z6esJ759kYOPX3VIpbX1Sf77YicoiN2rpnhC4XKWDCstq9oISZKmtVXzNrstv8CiM VbOIRJXzX3CjD1xEF5wGaBJVpig7ZPikQwP/HgLVsK3D7mFR1Z/WmwLhwJaESJrizOozCy YZykRrFi+5GD1expZSlxv1lWqTksjls= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-311-PGpcj-vVO1OxwmU-AfpZmw-1; Mon, 19 Dec 2022 06:13:19 -0500 X-MC-Unique: PGpcj-vVO1OxwmU-AfpZmw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1CDD0811E6E for ; Mon, 19 Dec 2022 11:13:19 +0000 (UTC) Received: from prancer.redhat.com (unknown [10.33.36.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C49EA1121314 for ; Mon, 19 Dec 2022 11:13:18 +0000 (UTC) From: Nick Clifton To: binutils@sourceware.org Subject: Commit: Add more tests for corrupt DWARF data Date: Mon, 19 Dec 2022 11:13:17 +0000 Message-ID: <87r0wvsl2q.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-9.7 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_H2,SPF_HELO_NONE,SPF_NONE,TXREP 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: Hi Guys, I am applying the patch below to add a couple more tests to binutils/dwarf.c to catch cases of corrupt DWARF information. Cheers Nick binutils/ChangeLog 2022-12-19 Nick Clifton PR 29914 * dwarf.c (fetch_indexed_value): Fail if the section is not big enough to contain a header size field. (display_debug_addr): Fail if the computed address size is too big or too small. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 03b36afcec0..b792902c496 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -739,6 +739,13 @@ fetch_indexed_value (uint64_t idx, return -1; } + if (section->size < 4) + { + warn (_("Section %s is too small to contain an value indexed from another section!\n"), + section->name); + return -1; + } + uint32_t pointer_size, bias; if (byte_get (section->start, 4) == 0xffffffff) @@ -7770,6 +7777,13 @@ display_debug_addr (struct dwarf_section *section, header = end; idx = 0; + if (address_size < 1 || address_size > sizeof (uint64_t)) + { + warn (_("Corrupt %s section: address size (%x) is wrong"), + section->name, address_size); + return 0; + } + while ((size_t) (end - entry) >= address_size) { uint64_t base = byte_get (entry, address_size);