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.133.124]) by sourceware.org (Postfix) with ESMTPS id 30C073847700 for ; Wed, 3 Apr 2024 10:19:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30C073847700 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 30C073847700 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712139570; cv=none; b=Q4D3n/HH1dDRbAuLQ63IfcT+eIoXpZkvABlXvUyyhS5rvBZ5ZYw/jRrGb4t/+D0ePUtNO4TDbFRikdXmIyPEHnoglgtSTOKYNI0hfOWPwjQXuAkai/iI8yJWS3xvONim7QrbDf/TtJWIFxhngIShNnaItgNwUvBn8Me5srprUdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712139570; c=relaxed/simple; bh=zdZ8RkPlH0JsEC9GoS3RYMdietLFEWMgecYFKXRa5JA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hdjwHMAfc5WLcuPFRpoHyxhWgdvms0ytHbJJlUxE3/eBFmQI/jhwCi6EkSD0y1TnzE8DnWMO8VD8ecmTWYLZwhV8dOA5WzftJVdiJ92zihrS79Lurw7qzQwcgH97TfWlRJPImkLixgTDMkOZEp7mOhVl98sp11rWVkIA5LmqXmE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712139568; 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=saoEOb4gDHT08H0vSklihk6dlMMJbNkeSB7lXX7TfCM=; b=My4YO0heJFXP58PRV1wjHxwFgbOWpRRohzz8CktH+AG94V+4KQ0wVTBsC8XspZ6TksyEtv y1GCoosSQvHur5B9pZMoNe7sdXAS1lGVlCFkj/ggq84EFaZ4zpiGQkktnuoRff1qz5AxLd dtNCxRZCWRvY1bnVsbCC8E9yz/TebLA= 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-16-nes2MEgUP_KkCx3SjG-DoA-1; Wed, 03 Apr 2024 06:19:27 -0400 X-MC-Unique: nes2MEgUP_KkCx3SjG-DoA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 498CF28B6981 for ; Wed, 3 Apr 2024 10:19:27 +0000 (UTC) Received: from prancer.redhat.com (unknown [10.42.28.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AADBA4073484 for ; Wed, 3 Apr 2024 10:19:26 +0000 (UTC) From: Nick Clifton To: binutils@sourceware.org Subject: Commit: Fix seg-fault in dwarf.c:process_debug_info Date: Wed, 03 Apr 2024 11:19:04 +0100 Message-ID: <87o7aqn3zb.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-9.8 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 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 recently discovered that I could not examine the debug info in the libc shared library without running into a null-pointer dereference: $ readelf -wi /lib64/libc.so.6 [...] Segmentation fault (core dumped) The issue is code in process_debug_info() which checks for a negative rnglists_base without first testing to make sure that a value exists. So I am applying the patch below as an obvious fix for the problem. Cheers Nick diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 92a07e00e9b..ce508d0315f 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -4248,14 +4248,17 @@ process_debug_info (struct dwarf_section * section, compunit.cu_version, debug_info_p); - /* This check was in place before, keep it. */ - stemp = debug_info_p->rnglists_base; - if (stemp < 0) + if (debug_info_p) { - warn (_("CU @ %#" PRIx64 " has has a negative rnglists_base " - "value of %#" PRIx64 " - treating as zero"), - debug_info_p->cu_offset, stemp); - debug_info_p->rnglists_base = 0; + /* This check was in place before, keep it. */ + stemp = debug_info_p->rnglists_base; + if (stemp < 0) + { + warn (_("CU @ %#" PRIx64 " has has a negative rnglists_base " + "value of %#" PRIx64 " - treating as zero"), + debug_info_p->cu_offset, stemp); + debug_info_p->rnglists_base = 0; + } } }