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 6C4D23858C60 for ; Thu, 14 Mar 2024 17:45:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C4D23858C60 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 6C4D23858C60 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=1710438336; cv=none; b=tK+d0u8uWzjo7yEKwUM/x28rLVc20cZ7NvJxTXrWlr21UFKmvvR5UTJmjAbTHO9EA8djdFEi/jEvuoFPVan3iKNgQqTLXNhBW3p4cJw2z3LoJ6Gno2zxJeJ5+PvbJO9LRd/0vJ4EIbxn+w7D8PYWlwVAF40zrS6PRzoLjzz3QQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710438336; c=relaxed/simple; bh=3EjNbYLxGwFTm+7P5DEiKknyD2nwXCopuek+88GcvIE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=CbkZeQsslb6tpywc9FrYD6pMrvvMX4C7wKLzuUsIH3BDhEx1prgE2Fk98pH13mUny33thceB7y+tq5rpqACouD+kjzeO8ubozx3RaIgLBG1lTBQsfDPbKuqvk//DPJ72AfPZz7XEQVB3HSyAfssQB9usKzdeS9WCL/CCw1BDFGA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710438334; 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: in-reply-to:in-reply-to:references:references; bh=vwdK3e9WHJkx1DLnQEFLXLjGEPlNl4xNWx5kkvScEGc=; b=gPtycQFlb+FIxQceSMWnJVpDvNxKCPKlUkq18D2n1b/GnbMMJNccFz8KTTK+pr28z8whYC Ts5rs7EfkAcS3jQ9eE3/sxuZhd0h5K0OOVwbteTXcrCnERZ/rfcaYPZ852AKjjEnBrf1zo ZIyZ0YKuwUs/Pq71yyotntBh68GPkkk= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-301-2bA02u88MA-TX_zQE5dm_A-1; Thu, 14 Mar 2024 13:45:32 -0400 X-MC-Unique: 2bA02u88MA-TX_zQE5dm_A-1 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-29be10b5429so998423a91.0 for ; Thu, 14 Mar 2024 10:45:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710438331; x=1711043131; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vwdK3e9WHJkx1DLnQEFLXLjGEPlNl4xNWx5kkvScEGc=; b=U6hM4n+VNq5QirxsdDvOxBHhFm5JovtiJJfwwV0aKDUwNXGV0wvHQ8F3obHxtlPfyy dTJhE5omAgsflPRCUrGikg5jsWt/E48fU4LSrnakYGZktZWpEor9m99dxHtddDG/Sn+6 KXGMsUxkgvzQ8AQ3OSXP5X/teDt8HT8EaASiXANK9mAjZEePkOKOsmD/uaO49skQ3r3Y BewvzKw6o+ckJSO0iSt1goi51qW9bI6vZJ0WEOu+LfiRTVl3kZD78s/dk+s9RJ+aK4T3 tjEBr3zjcNTj8111/ZpESraFQ6tqmGwk8veMBISgLx9LtQTmSNfSUo6wSpqknuXjr3s1 W/nQ== X-Forwarded-Encrypted: i=1; AJvYcCWxu2dlhXiBDwnj8bd0RIaI9foisYBZbptApIISQiAePorVOjUir3+T8B8GdEAktjEQ2MkmcvlBenUXgap3UNtm5OVetFcPR/RzDA== X-Gm-Message-State: AOJu0Yz301XzrYpDIw5UV6xVedj1vu1plYofmGLdj5QRvgpYTsGdkg5M I7RZuEaVmBErDmbK+U/mqVUOYjY672f+rN5eNm4VZ5w0KQeuo8BZso5vW7FEkXb1CAT87d6ICbG txcVWlQCZlU7XA+R4D9s84kNhYuJVdRptj2NST7QEnK5a1VhnHARWBKPMe6quIuSOfjZZgkqTTq uC+DevFEoR1P98ggdUFBKtxyAfQ38TvhYLakYVftdFt0Y= X-Received: by 2002:a17:90a:3007:b0:29b:af80:7395 with SMTP id g7-20020a17090a300700b0029baf807395mr3809184pjb.4.1710438331462; Thu, 14 Mar 2024 10:45:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyTeBqnkEm1nSUNC6s8IpsD7Y28SiQTum1jbNP7scBgDDMxwLCxnxRoPuYEdLv+vzqU3IluReiKrzgVGBcQEA= X-Received: by 2002:a17:90a:3007:b0:29b:af80:7395 with SMTP id g7-20020a17090a300700b0029baf807395mr3809161pjb.4.1710438331040; Thu, 14 Mar 2024 10:45:31 -0700 (PDT) MIME-Version: 1.0 References: <20240313201827.1853989-1-amerey@redhat.com> <878r2lm1un.fsf@tromey.com> <22883d8d-b634-4e71-802c-239114d01279@simark.ca> <87r0gclw9w.fsf@tromey.com> In-Reply-To: <87r0gclw9w.fsf@tromey.com> From: Aaron Merey Date: Thu, 14 Mar 2024 13:45:20 -0400 Message-ID: Subject: Re: [PATCH] gdb/dwarf2: Check for missing abbrev To: Tom Tromey Cc: Simon Marchi , gdb-patches@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: On Wed, Mar 13, 2024 at 9:47=E2=80=AFPM Simon Marchi wro= te: > > We generally don't make functions error out like this if they are passed > bad parameters (we can use gdb_assert for that if we really want to). > It's up to the callers to respect the contract and not pass nullptr > where nullptr is not expected. So I would instead suggest to add the > nullptr check in the caller (in scan_attributes itself, after the > peek_die_abbrev call lower). Moving the nullptr check after peek_die_abbrev is fine, but replacing the throw with 'return nullptr' doesn't fix the crash. It looks like scan_attributes currently cannot return nullptr without triggering a crash. > However, I'd like if we could analyze the problem a bit further to > understand more precisely what happens, just to be sure that there isn't > a more fundamental problem and we're not just papering over the problem. > I added instructions on the bug that should help you reproduce. > > What I see is that read_unsigned_leb128 in peek_die_abbrev unexpectedly > returns 0. Is it because the corrupted file contains zeros where it > shouldn't? Or is the file truncated and we are reading past the end of > the buffer, and there happens to be a zero there? The corrupt debuginfo that the reporter used to reproduce this [1] is the same size as the non-corrupt version. A diff of hex dumps of the corrupt and non-corrupt versions of the debuginfo show that the corrupt file differs by containing all zeros in some places. On Thu, Mar 14, 2024 at 8:36=E2=80=AFAM Tom Tromey wrote: > > Also, I was wondering if this case can be tested somehow. Perhaps the > DWARF assembler could be modified to allow the creation of corrupted > debug info. It seems to me if we're going forward with the security > policy, then we're going to need to test these things. We should be able to reproduce this in a testcase by overwriting part of a small binary with zeros. I'll resubmit the patch with a testcase. Aaron [1] https://sourceware.org/bugzilla/show_bug.cgi?id=3D31478