From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 44980385840C; Wed, 10 Nov 2021 14:11:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44980385840C From: "bryanmcsp at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug remote/26614] AddressSanitizer: heap-use-after-free of extended_remote_target in remote_async_inferior_event_handler Date: Wed, 10 Nov 2021 14:11:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: remote X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bryanmcsp at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 10.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2021 14:11:37 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26614 Takkelink changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bryanmcsp at gmail dot com --- Comment #46 from Takkelink --- The problem is here in remote_async_inferior_event_handler: ... static void remote_async_inferior_event_handler (gdb_client_data data) { inferior_event_handler (INF_REG_EVENT); remote_target *remote =3D (remote_target *) data; remote_state *rs =3D remote->get_remote_state (); ... The remote target (passed in the data argument) can be destroyed during= the call to inferior_event_handler. If so, the call to remote->get_remote_state () is done using a dangling pointer. Fix this by increasing the reference count on the remote target before calling inferior_event_handler, such that it won't get destroyed until right be= fore returning from remote_async_inferior_event_handler. https://www.blfplumber.com Tested on x86_64-linux. Intended for gdb-10-branch. The problem has stopped reproducing with the trigger patch since master commit 79952e69634 "Make scoped_restore_current_thread's cdtors exception free (RFC)". We could still apply this to master though. gdb/ChangeLog: --=20 You are receiving this mail because: You are on the CC list for the bug.=