From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIHg3-0004lh-0b for qemu-devel@nongnu.org; Wed, 29 Jun 2016 11:45:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIHfz-00030L-Ns for qemu-devel@nongnu.org; Wed, 29 Jun 2016 11:45:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIHfz-00030G-IO for qemu-devel@nongnu.org; Wed, 29 Jun 2016 11:45:19 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC6177109B for ; Wed, 29 Jun 2016 15:45:18 +0000 (UTC) References: <1467213840-14206-1-git-send-email-pbonzini@redhat.com> <1467213840-14206-3-git-send-email-pbonzini@redhat.com> <981859396.766716.1467214284491.JavaMail.zimbra@redhat.com> From: Paolo Bonzini Message-ID: <0a8ed026-c8dd-11a6-07b1-3e7ea41b31c7@redhat.com> Date: Wed, 29 Jun 2016 17:45:15 +0200 MIME-Version: 1.0 In-Reply-To: <981859396.766716.1467214284491.JavaMail.zimbra@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PULL 32/35] vhost-user: disable chardev handlers on close List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= Cc: qemu-devel@nongnu.org, =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= On 29/06/2016 17:31, Marc-Andr=C3=A9 Lureau wrote: > Hi >=20 > ----- Original Message ----- >> This otherwise causes a use-after-free if network backend cleanup >> is performed before character device cleanup. >> >> Cc: Marc-Andr=C3=A9 Lureau >> Signed-off-by: Paolo Bonzini >=20 >=20 >=20 > See also my previous (still unreviewed) series: > https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg01004.html Oh, interesting! This is indeed a superset of patch 1, but you need to either delete the chardev (patch 2) or clear the handlers. There are only a handful uses of qemu_chr_delete outside qemu-char.c, which makes me believe that most of them are wrong... Paolo > so: Reviewed-by: Marc-Andr=C3=A9 Lureau >=20 >=20 >> --- >> net/vhost-user.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/net/vhost-user.c b/net/vhost-user.c >> index 636899a..92f4cfd 100644 >> --- a/net/vhost-user.c >> +++ b/net/vhost-user.c >> @@ -151,6 +151,11 @@ static void vhost_user_cleanup(NetClientState *nc= ) >> vhost_net_cleanup(s->vhost_net); >> s->vhost_net =3D NULL; >> } >> + if (s->chr) { >> + qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, NULL); >> + qemu_chr_fe_release(s->chr); >> + s->chr =3D NULL; >> + } >> =20 >> qemu_purge_queued_packets(nc); >> } >> -- >> 1.8.3.1 >>