Message ID | 20230531160406.3932028-3-lancelot.six@amd.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 263023857034 for <patchwork@sourceware.org>; Wed, 31 May 2023 16:06:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 263023857034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685549177; bh=Cvcx1bY9iQgyseKH5X9Jpi4/DZ+tYLCRq78UXsh/OCs=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MBGJqg0h6Xb01JBuDG6/qHE3uI0/2KP/wTqJ4eDwbyhtblaZlkL6m4GyBEEfd8Awx txck1/vRLqSSrGZT+r/a2V6ftsSCynFTGJH48W8cE97VVCKkmV9y+mYRrRfIWGLxij jQAFu0Q+B/zzh6/rZMKvVzI+qCZgiTSEu6F/iXQE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) by sourceware.org (Postfix) with ESMTPS id 3BC1E3858D20 for <gdb-patches@sourceware.org>; Wed, 31 May 2023 16:05:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BC1E3858D20 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fTRWRNoQYYAeFFTB0jR0AlAhElMnFa2tpVy2TR9JnTrQkV2qyewsrgykl9XZQrvgqrpcy6Qiw1NhY9byCzpvnsDQu6wFFgb0z8tiznVZ1KVX9UNQQormG6/fHn7lpbk3EllCjB+8+zBVihV9Z2Ie5jLwC2gLrPYx2ymoiTGEVvrpFCU4YP2WuJVOcIDeKU8LpfW9Z/jqYhGiLxJTBPv/DashkN16QWpOFS2GpShHOsIgfvdtDPQzYB1dPkLB721QXW4w8pLAkOGPxjILoe5eyjzoVkbO38qukWM7FzmV+TptztfY70YOavGz0Ty/hFgjJqNKOOTqfnvtxUvoD/eH3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Cvcx1bY9iQgyseKH5X9Jpi4/DZ+tYLCRq78UXsh/OCs=; b=NVA5UKSgSV8Fut8VpQLXa1tTYJ5KAdytRyYHetfacVoKefqtsBmkQ71rEcrHgEdP4kUA6W8LaENjm1b9Ehk9DE3NSdQH5l3Za3RocILSK2asKY6dwyM3MZYW0peUFVGb0SeSKAQNYJdtnTFEIQ2KWSBwR3bjfhF2mchII2yOaNbJHAunMH59ybOf791AgeAPkRXhJxtPzvdVmgEHns6atVQpKO2DcVO5foo7Zui+CY2aSDYne2r6ViKvoZvbQgAn4+zkWmHl3X+hXvf0spnsNzcrJGkCa7OET2RKGci1e4M38JBdJeDfUc7FUktDlLLDLRkIA1aMZ1K5rfgVp0s7xA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from MN2PR05CA0059.namprd05.prod.outlook.com (2603:10b6:208:236::28) by IA0PR12MB8981.namprd12.prod.outlook.com (2603:10b6:208:484::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Wed, 31 May 2023 16:05:37 +0000 Received: from BL02EPF000145B8.namprd05.prod.outlook.com (2603:10b6:208:236:cafe::36) by MN2PR05CA0059.outlook.office365.com (2603:10b6:208:236::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Wed, 31 May 2023 16:05:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF000145B8.mail.protection.outlook.com (10.167.241.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.18 via Frontend Transport; Wed, 31 May 2023 16:05:37 +0000 Received: from khazad-dum.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 31 May 2023 11:05:36 -0500 To: <gdb-patches@sourceware.org> CC: <lsix@lancelotsix.com>, Lancelot SIX <lancelot.six@amd.com> Subject: [PATCH 2/3] gdb/corelow.c: avoid repeated warnings in build_file_mappings Date: Wed, 31 May 2023 17:04:05 +0100 Message-ID: <20230531160406.3932028-3-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531160406.3932028-1-lancelot.six@amd.com> References: <20230531160406.3932028-1-lancelot.six@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000145B8:EE_|IA0PR12MB8981:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ee376b1-53a0-4e79-b636-08db61f0dfc3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0QqpxBaeSKvSXd+O6Dg9uztrk5q+7Md+OfDZNTfu+UH4+gALa2b5g50GsBnxfKYyyqzIlDB5Y9+OG9PW/xqz7T4n5l5wd3tAxjDPxC5jcAs9KMW5lALIQSrOhhXxXqiGuY9CrUv7Ocdtg85U1aVctrEExxVIMgNbFOtaZB9yLdPQ1MNn2uAPRF0wiapTI4WSfCDkEIoxcu3hiuUiwuyEHL4ErdlSknzo1rJdnNUZndm8BANBxzc50uG0kMMjOFOJSfsoMqJXwnGCNKpoo6bGNjpV+jLe/Qc/XObtvS+8PHni5Tu05PCqs9pkf4rGnwyC7njE2g7A7udG9r10dy9mqMvdJde04KH5LpcuLH20LArTS1BKi8NIbu8RrshHJigWRtiDcT8lFIi0mA2ULWBvyPKQXiFZ/gxe8yn7mzJCmncdDN1/ca4l6olQyCzOlQiO4E7OMfr6aSwu+3mPWsRZM4Su/S75BqMDCR6q+KrG2JiUD9DQhmq4f2H2yReVr1v+fjN/U55SeGqvTw1n9EsFeEvqJj+2gScfwhD+l5cXfEhS3nJADC06Wp+VyhIgYWpv7bp88kYr9pOssKdd5qAmsbzU5WtAVYFQFZoqG/50BqIqwIk6ETjCszqtvSlAvrZB1EtvRfctCuHYEqGGU9m2jH8wo+YHPl471yYmxqXTxhR4p94ii2o61lcqLbafmOoTxhvNQ2hDKRRaiT7l1T0CIxm0ls8fH1gDEv/7JJgjnzZW0BaPYhA/6V0L8eTedJtDr58a4/0S7fntj8faF1ZjjQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(136003)(346002)(396003)(39860400002)(376002)(451199021)(40470700004)(36840700001)(46966006)(86362001)(36756003)(316002)(4326008)(478600001)(54906003)(6916009)(70206006)(70586007)(6666004)(7696005)(47076005)(82310400005)(82740400003)(40480700001)(8676002)(8936002)(41300700001)(2906002)(5660300002)(2616005)(356005)(81166007)(336012)(16526019)(426003)(26005)(186003)(1076003)(36860700001)(83380400001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2023 16:05:37.6779 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ee376b1-53a0-4e79-b636-08db61f0dfc3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000145B8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8981 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Lancelot SIX <lancelot.six@amd.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Fix use-after-free in gdb/corelow.c + cleanups
|
|
Commit Message
Lancelot Six
May 31, 2023, 4:04 p.m. UTC
When GDB opens a coredump it tries to locate and then open all files which were mapped in the process. If a file is found but cannot be opened with BFD (bfd_open / bfd_check_format fails), then a warning is printed to the user. If the same file was mapped multiple times in the process's address space, the warning is printed once for each time the file was mapped. I find this un-necessarily noisy. This patch makes it so the warning message is printed only once per file. There was a comment in the code assuming that if the file was found on the system, opening it (bfd_open + bfd_check_format) should always succeed. A recent change in BFD (014a602b86f "Don't optimise bfd_seek to same position") showed that this assumption is not valid. For example, it is possible to have a core dump of a process which had mmaped an IO page from a DRI render node (/dev/dri/runderD$NUM). In such case the core dump does contain the information that portions of this special file were mapped in the host process, but trying to seek to position 0 will fail, making bfd_check_format fail. This patch removes this comment. --- gdb/corelow.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
Comments
Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org> writes: > When GDB opens a coredump it tries to locate and then open all files > which were mapped in the process. > > If a file is found but cannot be opened with BFD (bfd_open / > bfd_check_format fails), then a warning is printed to the user. If the > same file was mapped multiple times in the process's address space, the > warning is printed once for each time the file was mapped. I find this > un-necessarily noisy. > > This patch makes it so the warning message is printed only once per > file. > > There was a comment in the code assuming that if the file was found on > the system, opening it (bfd_open + bfd_check_format) should always > succeed. A recent change in BFD (014a602b86f "Don't optimise bfd_seek > to same position") showed that this assumption is not valid. For > example, it is possible to have a core dump of a process which had > mmaped an IO page from a DRI render node (/dev/dri/runderD$NUM). In > such case the core dump does contain the information that portions of > this special file were mapped in the host process, but trying to seek to > position 0 will fail, making bfd_check_format fail. This patch removes > this comment. LGTM. Reviewed-By: Andrew Burgess <aburgess@redhat.com> Thanks, Andrew > --- > gdb/corelow.c | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) > > diff --git a/gdb/corelow.c b/gdb/corelow.c > index 77fc4453f94..ce68f91132e 100644 > --- a/gdb/corelow.c > +++ b/gdb/corelow.c > @@ -264,18 +264,11 @@ core_target::build_file_mappings () > if (bfd == nullptr || !bfd_check_format (bfd, bfd_object)) > { > m_core_unavailable_mappings.emplace_back (start, end - start); > - /* If we get here, there's a good chance that it's due to > - an internal error. We issue a warning instead of an > - internal error because of the possibility that the > - file was removed in between checking for its > - existence during the expansion in exec_file_find() > - and the calls to bfd_openr() / bfd_check_format(). > - Output both the path from the core file note along > - with its expansion to make debugging this problem > - easier. */ > - warning (_("Can't open file %s which was expanded to %s " > - "during file-backed mapping note processing"), > - filename, expanded_fname.get ()); > + if (unavailable_paths.insert (filename).second) > + warning (_("Can't open file %s which was expanded to %s " > + "during file-backed mapping note processing"), > + filename, expanded_fname.get ()); > + > if (bfd != nullptr) > { > bfd_close (bfd); > -- > 2.34.1
diff --git a/gdb/corelow.c b/gdb/corelow.c index 77fc4453f94..ce68f91132e 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -264,18 +264,11 @@ core_target::build_file_mappings () if (bfd == nullptr || !bfd_check_format (bfd, bfd_object)) { m_core_unavailable_mappings.emplace_back (start, end - start); - /* If we get here, there's a good chance that it's due to - an internal error. We issue a warning instead of an - internal error because of the possibility that the - file was removed in between checking for its - existence during the expansion in exec_file_find() - and the calls to bfd_openr() / bfd_check_format(). - Output both the path from the core file note along - with its expansion to make debugging this problem - easier. */ - warning (_("Can't open file %s which was expanded to %s " - "during file-backed mapping note processing"), - filename, expanded_fname.get ()); + if (unavailable_paths.insert (filename).second) + warning (_("Can't open file %s which was expanded to %s " + "during file-backed mapping note processing"), + filename, expanded_fname.get ()); + if (bfd != nullptr) { bfd_close (bfd);