From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2044.outbound.protection.outlook.com [40.107.7.44]) by sourceware.org (Postfix) with ESMTPS id C957038518B0 for ; Mon, 12 Dec 2022 15:05:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C957038518B0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JINZVpB1bE8mtOnjGcKHm/971IsMc7NPsw6VXj1fpVk=; b=CceFEhr2hF2AKInbmHQ7rze5wUrP/CF6LpkDDT9er6OigBbsDE3EmJdIbLYHQkfiCxuKjDlbasAqekitX0uG998a7Rw1M9m3A/totUhK+QYPZ/o1dBJtSToEf+NL93VW7jdlCRnArJCMG/sLaIjW7hCJPjJ4svNkFGPvisxfA2I= Received: from DU2PR04CA0242.eurprd04.prod.outlook.com (2603:10a6:10:28e::7) by AM8PR08MB5858.eurprd08.prod.outlook.com (2603:10a6:20b:1dc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.9; Mon, 12 Dec 2022 15:05:51 +0000 Received: from DBAEUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::bc) by DU2PR04CA0242.outlook.office365.com (2603:10a6:10:28e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Mon, 12 Dec 2022 15:05:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT013.mail.protection.outlook.com (100.127.142.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.21 via Frontend Transport; Mon, 12 Dec 2022 15:05:50 +0000 Received: ("Tessian outbound 73ab5f36653e:v130"); Mon, 12 Dec 2022 15:05:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6c9f16f1cfd23958 X-CR-MTA-TID: 64aa7808 Received: from 479963dc8f30.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 98B32482-86CB-4C85-ABAF-45139BB00CA8.1; Mon, 12 Dec 2022 15:05:42 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 479963dc8f30.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 12 Dec 2022 15:05:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d77wj2DiGm4QwENXJy6CrgYSyrY9Wd3LPh14i+AuM8u6g4O6jT6IIj664RGLn//xio/iwZ5DTMEKQXHX540dTDl+6a1P6VenWOLTX1GyA0TQ33xeSuAUtvktebX1oNBACE0Y9aiR6vVGFsIhddLKvSCO1JOVbUoIHgSYuG2EaVpD+v87jl7o2+voH87j6KI2KQEq4JmEHT2xtujDAW4cNLZXGIbPes7sBo2PMVAQpvSbUNBkr4rVJbITKeuqyNMxGTVxhuAN4VurDimGec9XSV5ld/FDdnR8SoAdElhXnzitkzkXN6wtUkGm78DOxoc8UI2E0bXDiM9PcJHxtiLdZQ== 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=JINZVpB1bE8mtOnjGcKHm/971IsMc7NPsw6VXj1fpVk=; b=kG7Nv7IBG91syt6UPRREmvJcfIWJqHGEBXb1WH+N5miLW1DDENc6Y4WQNM8JcmJ1Z0Of+eGN5hjYYeLOuKmewG7yRvFUl8XAaNstNsicKqAponrfQxDAFcSWtOyGgYE36YoFdG+EfQh9K87oFZ+hI+5bRFfUwQS9IF/FHWaDYZf/Y28XDDjmwCPgICjHj/DEC7EG2a2+oUea6+jbqvGxwMx+xmIJJxmKL3/279Eyjhn6bL5Cd2CxtIFuhOlj2ynJFXtrTeE41r2Y7gX/sCAHwRrUfFxlZxz35rSsQ0pMdfpg5h6nFkXe2vxYy+IXKIW/fflvJKzyEjidI/hnd8Oouw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JINZVpB1bE8mtOnjGcKHm/971IsMc7NPsw6VXj1fpVk=; b=CceFEhr2hF2AKInbmHQ7rze5wUrP/CF6LpkDDT9er6OigBbsDE3EmJdIbLYHQkfiCxuKjDlbasAqekitX0uG998a7Rw1M9m3A/totUhK+QYPZ/o1dBJtSToEf+NL93VW7jdlCRnArJCMG/sLaIjW7hCJPjJ4svNkFGPvisxfA2I= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by VE1PR08MB5584.eurprd08.prod.outlook.com (2603:10a6:800:1a4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.9; Mon, 12 Dec 2022 15:05:37 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::eed7:25a3:e4ea:187a]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::eed7:25a3:e4ea:187a%7]) with mapi id 15.20.5924.009; Mon, 12 Dec 2022 15:05:37 +0000 Message-ID: <1a96057b-afd6-1e90-15c9-ee106a2998c7@arm.com> Date: Mon, 12 Dec 2022 15:05:33 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH] gdb: fix possible use-after-free when executing commands Content-Language: en-US To: Tom Tromey , Jan Vrany via Gdb-patches Cc: Jan Vrany References: <20221208142014.84759-1-jan.vrany@labware.com> <87pmcsh37h.fsf@tromey.com> From: Luis Machado In-Reply-To: <87pmcsh37h.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LNXP265CA0036.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::24) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|VE1PR08MB5584:EE_|DBAEUR03FT013:EE_|AM8PR08MB5858:EE_ X-MS-Office365-Filtering-Correlation-Id: 3acb6d02-028a-4310-3a68-08dadc525b1e x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: hMParJ0q7gNUKGi/4ysznjVgLwxJQrFb/ujkYN/Dkk5veH4aeQi4PSlulqetKaqjhBdw9zULHe4HUqFokdr4c2W2xruvMZOQPR4bP8H/9zblKt0fzOOWNUB7A7lvApLKjYWEolHh8xmFQ9A16r8/cLeOOXk2XN2E/Z4yZEq5tTUL5yd+n0NEmb5HSoXwc4kAxmIR+m8NZnKrdCvm4mgbTUCLRFs3mds5Jp+dHTXSjFHShwmvGVgAtYSMuGWObauMYwJZd9DB9hfi9Y1YEsocSdHNWKEW68Zde+5EpldhyAHwX/f5x5NhxSqxYFmMOFjM4+4oQzVOCV+LH4VmsnUEspIBvXSgFfwiP96hurQ/MCNB/g2r366eG3Pl70iwAF6XyvsF2JuCVUjyMRNY6zkrC8pXmtV4gvkWS/fOeJp0lAuRtYfzfHwu3hdGvr2luCyHcYHNUDa/bJ/gv8TBuklihwaISzreTTiOVNxQZ6rV9z9Dhcs1M0oX2js1rIXeEJ12GopuhlzDAeHXKetBhilCETfGHrs/K0+eDRo9/t44urnLyoQu7w5FnzZHluA6uPazT1XwIdX3v2hyb5qC138B53CHOGEUWkAdjh+zwbJxlaMgPTKroyZvTs65sA019u9PML+nXOEtsldTE1HhCfbG+9OCtQZVTG5lU2zs5DhncfvnKNX/A56dy+0vVxNqUaGSWymbn70L/DMqzbhD883XAEZsvSCyOrqLh/0WFuA6Rqc0Uw9Ecbkw82x+8KfY4OnF X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(39850400004)(346002)(376002)(366004)(451199015)(84970400001)(66899015)(36756003)(110136005)(31696002)(86362001)(38100700002)(5660300002)(8936002)(2906002)(31686004)(44832011)(41300700001)(316002)(2616005)(4326008)(66946007)(66556008)(66476007)(6506007)(8676002)(186003)(6666004)(26005)(478600001)(53546011)(6486002)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5584 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 614bc43d-b578-4ffc-ee71-08dadc52536d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oDmgUsSSM9Y8SX0oYbCMaa4coFd4fNF21JEDPOyeuWtqxxPC6II+2Pnphf1TkTw/App8+eWNnCfglbXSGuhHg0L0BmfZv1LhbdrUowSyrlnhTFKknU5Kj52sIB9S1M0LRJaJEqYLNfFb/Z+ZvZHoxwKQGc5xpDWDR7eHNkbewdkzIjWVLDF+32kydo+WkWNSCTidUZ+2B73RLOXX/wZAmSMBNqkgKMVWHWT7cJsnxhtiqv8gPKamoM9GPnwL1Z4MQftRHSPMCfDnbkV5jd++vjA99AKIMYR09hsou5T/lLtGevLstKUFh4Pwo9O5KkrhStPuk5YHdi3wQJTRnPAXWaJRluYIKph3mfDjoqkV1qLNqFSIGPYzKzsJRHi5F2Hxg02Q8Mn76xhsSOeaDTMHdesXb6bUjJjTL0Zn0Jcqa0jvn2zfkauacxWUvO0m3mIXCr0VTzLplop6QoEjYnDxd0+KcGTcPaLNqULfYvEnGo6suSKKIfIeZ1pPHhhyYw+Ppp4akEjrVph5bDR5B5CTpJbeV/JPtKjln3/xbCPMis7vU93I9qPZtaVFivPuA/2MtYSk20ePGHFZZwriZfPdZ0p8hiwUUNqoR6dMeNyaZhgnVm/ccwBDH45reQDGFyx1eKGUnzyfcJoW2KjkyR5gWD1029IduyCeZg4iHUCgJEZSYUvTziufYl6IXBpJ7GZhs1CgXWd/h+KCcg0nzhF2uxpA5Rpb6E4OqbjTy170UeNYB6JSdpT9keVY27/A3lt9h6VQdg7tuhleped6SLAVwg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(136003)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(8676002)(66899015)(4326008)(84970400001)(40480700001)(86362001)(5660300002)(31686004)(36860700001)(40460700003)(31696002)(8936002)(110136005)(44832011)(316002)(36756003)(186003)(26005)(53546011)(6512007)(6506007)(6666004)(47076005)(356005)(81166007)(2906002)(336012)(41300700001)(70586007)(70206006)(478600001)(6486002)(107886003)(82310400005)(2616005)(82740400003)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2022 15:05:50.0326 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3acb6d02-028a-4310-3a68-08dadc525b1e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5858 X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=no 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, On 12/9/22 17:55, Tom Tromey wrote: >>>>>> "Jan" == Jan Vrany via Gdb-patches writes: > > Jan> This may lead into use-after-free error. Imagine the command > Jan> being executed is a user-defined Python command that redefines > Jan> itself. In that case, struct `cmd_list_element` pointed to by > Jan> `c` is deallocated during its execution so it is no longer valid > Jan> when post hook is executed. > > Thanks for the patch. > > Your analysis makes sense to me. I wouldn't be surprised if there were > other issues along these lines. Or if this were in bugzilla somewhere. > > Jan> + std::string c_name(c->name); > > Space before the paren. Also I think a comment here explaining why it's > needed would be good. > > Jan> /* If this command has been post-hooked, run the hook last. */ > Jan> - execute_cmd_post_hook (c); > Jan> + c = lookup_cmd_exact (c_name.c_str (), cmdlist); > Jan> + if (c != nullptr) > Jan> + execute_cmd_post_hook (c); > > Perhaps a comment here as well explaining the need to redo the lookup. > > This is ok with these minor changes. > > thanks, > Tom I've spotted gdb.base/define.exp failing today, and bisection stopped in this particular patch. target testsuite one hello (gdb) FAIL: gdb.base/define.exp: target testsuite with hooks