From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4xeDCrO1/Wo1jxwAWB0awg (envelope-from ) for ; Wed, 18 Nov 2026 09:26:59 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=sdKVNyE1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 04C1E1E0BC; Wed, 18 Nov 2026 09:26:59 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id ED9941E023 for ; Wed, 18 Nov 2026 09:26:57 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B38894BA2E31 for ; Wed, 18 Nov 2026 14:26:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B38894BA2E31 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=sdKVNyE1 Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 39A1D4BA5434; Wed, 18 Nov 2026 14:26:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 39A1D4BA5434 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 39A1D4BA5434 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795011992; cv=none; b=l4pT0A8dn8xgiwP8fDugcIHLvjDEgJJeoaR+cyrj2K4JMyPW+luszj8GvZfCsWTfWVqgYXPUJpbcypR7qMJfZA7bMwhuMBuMEHdPs2hunGZzMJD4Svc/FEJCaVYvfhIEmPdGsl8X2KuCQPEfCmQ2ovLVbJR6OjXAW8ZpuMVOYes= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795011992; c=relaxed/simple; bh=0afo8+UYvfXHee18VrecgK4q/D2+pgzPHmWWAugcHrw=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=XmD64LxaAOKKSTK6Hg8Z1m7jRKassUKOhkeF99KGj7qIyGFj7i6+Si7ug+SrjXW6l9s1yEssaD/YQJtXfT7f6NsnTEGTROA1TvhsTv7LzdtSpMncB0i8xNFejtgtx9b/Mg69G178ikyU4eKM/e01jiIsV360Lo4h1bSHhcDTWcM= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=sdKVNyE1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39A1D4BA5434 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTgcD-0007J7-FJ; Wed, 18 Nov 2026 09:26:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ZjFuVLhvrZLeHAXEcKwhf+PWf41VRs8e7l0r3hSf7BI=; b=sdKVNyE1ERJg YfwFbghBxldheuqyCd8GvTzv5vvh4DAYso90gq9DwCVmPuI20IDOfJ9Y4m8l73Dz5ACJnJK4ytMXk fdxYYB4lmoOfU8hmXHHg5AC+FX3aa7rlP/ALOz0FrPchInWEfhWcarbnI/O/JDbPvzwRJX72NRN9Z bX8f808m8vopN2pKG1FaI+0oYYzd6bRDWw4Ten8tZERPpEU8fuVOW3teT1Zr8ELYXht0KLqU0oM0J 979UmB3kN7P7SWjmnLrv+6rYkzgr9dVo8TCGiU3SIrb4uDjB6AtcFnsD27Yru3au/o7tog4livnJx bKTcTOc8xnq7/NctTNMXLg==; Date: Wed, 18 Nov 2026 16:26:23 +0200 Message-Id: <86h5hemd0w.fsf@gnu.org> From: Eli Zaretskii To: YuPeng Cc: gdb-patches@sourceware.org, tromey@sourceware.org,debianyu@163.com In-Reply-To: <1794998055185602167.295606@kylinos.cn> (message from YuPeng on Wed, 18 Nov 2026 18:34:15 +0800) Subject: Re: [PATCH] Fix use-after-free when Python Breakpoint.stop method deletes the breakpoint References: <1794998055185602167.295606@kylinos.cn> X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org > From: YuPeng > Cc: tromey@sourceware.org,debianyu@163.com > Date: Wed, 18 Nov 2026 18:34:15 +0800 > > If a Python Breakpoint.stop method calls self.delete(), the underlying > breakpoint is freed while bpstat is still processing it. > > delete_breakpoint tries to clear references with > bpstat_remove_bp_location, but that only walks > thread->control.stop_bpstat, which still points at the bpstat chain from > the previous stop (it is cleared in proceed()), not the chain currently > being built by bpstat_stop_status. The current chain therefore keeps a > dangling breakpoint pointer, and gdb crashes on the next access. > > The reproducer from the bug report returns False from stop(), so the > crash happens right after the callback while infrun examines the bpstat > chain (the report shows bpstat_explains_signal). > > Fix: > - Assign thread->control.stop_bpstat = bs_head before the check_status > loop in bpstat_stop_status, so bpstat_remove_bp_location can find and > nullify the reference in the chain being processed. > - In bpstat_check_breakpoint_conditions, return early if > bs->breakpoint_at became NULL after the extension language callback. > - In bpstat_stop_status, re-read b = bs->breakpoint_at after > bpstat_check_breakpoint_conditions and skip the entry if it is NULL. > > Tested on x86_64-linux with an ASan build: without the fix gdb aborts > with a heap-use-after-free; with it the breakpoint is deleted and the > inferior exits normally. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34379 > > I do not have an FSF copyright assignment on file; please let me know > if you think this change needs one. Thanks, but could you tell if the patch and the description were generated by LLM, by any chance?