From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3112D396ECA0; Thu, 7 Jan 2021 16:10:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3112D396ECA0 From: "vries at gcc dot gnu.org" 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: Thu, 07 Jan 2021 16:10:20 +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: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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: 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: Thu, 07 Jan 2021 16:10:20 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26614 --- Comment #25 from Tom de Vries --- (In reply to Simon Marchi from comment #21) > (In reply to Pedro Alves from comment #20) > > target_ops is reference counted. Wouldn't this patch fix the issue? > >=20 > > diff --git c/gdb/remote.c w/gdb/remote.c > > index 71f814efb36..5a5ac1ee92f 100644 > > --- c/gdb/remote.c > > +++ w/gdb/remote.c > > @@ -14174,9 +14174,13 @@ remote_async_serial_handler (struct serial *sc= b, > > void *context) > > static void > > remote_async_inferior_event_handler (gdb_client_data data) > > { > > + remote_target *remote =3D (remote_target *) data; > > + /* Hold a strong reference to the remote target while handling an > > + event, since that could result in closing the connection. */ > > + auto remote_ref =3D target_ops_ref::new_reference (remote); > > + > > inferior_event_handler (INF_REG_EVENT); > >=20=20 > > - remote_target *remote =3D (remote_target *) data; > > remote_state *rs =3D remote->get_remote_state (); > >=20=20 > > /* inferior_event_handler may have consumed an event pending on the >=20 > Hmm, right. I have my patch series almost ready to send, and I think it'= s a > desirable change in any case, so I'll still send it for review. Which was submitted here: https://sourceware.org/pipermail/gdb-patches/2020-November/173633.html --=20 You are receiving this mail because: You are on the CC list for the bug.=