From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2KIY-0007Xx-Nm for qemu-devel@nongnu.org; Wed, 02 Jul 2014 09:10:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2KIR-0005wC-8V for qemu-devel@nongnu.org; Wed, 02 Jul 2014 09:10:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2KIQ-0005w7-VJ for qemu-devel@nongnu.org; Wed, 02 Jul 2014 09:09:59 -0400 Message-ID: <53B40491.4000405@redhat.com> Date: Wed, 02 Jul 2014 15:09:37 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1404291017-7456-1-git-send-email-arei.gonglei@huawei.com> <53B3CB04.5040909@redhat.com> <53B3CFB8.5000800@huawei.com> <53B3D011.9000200@redhat.com> <33183CC9F5247A488A2544077AF1902086C18093@SZXEMA503-MBS.china.huawei.com> <53B3DBFD.1090009@redhat.com> <53B3EDFF.6010309@huawei.com> <53B3EF92.2020406@redhat.com> <53B3F3A6.1060707@huawei.com> <53B3F8EB.1010008@redhat.com> <30F7BCE3-5A87-4AA0-86CA-E467842FE3A5@icloud.com> In-Reply-To: <30F7BCE3-5A87-4AA0-86CA-E467842FE3A5@icloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] ide: fix double free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?6ZmI5qKB?= Cc: "kwolf@redhat.com" , ChenLiang , "Huangweidong (C)" , "qemu-devel@nongnu.org" , "Gonglei (Arei)" , "stefanha@redhat.com" Il 02/07/2014 14:54, =E9=99=88=E6=A2=81 ha scritto: >> > The second call should have happened within dma_aio_cancel's call to >> > bdrv_aio_cancel. This is the real bug. > IMO, the second need not happened within dma_aio_cancel's call to bdrv_= aio_cancel. > The double free will be happened if dam_aio_cancel is called. The callback must not be invoked after bdrv_aio_cancel. This is the=20 fundamental invariant of bdrv_aio_cancel. All implementations of AIOCB=20 must respect it, or bugs like this one happen. Here, either bdrv_aio_cancel was not invoked, or the invariant was broken. The other invariant, this time in dma-helpers.c, is that dma_bdrv_cb=20 either exits with no pending AIOCB, or it exits with a non-NULL=20 dbs->acb. If bdrv_aio_cancel was not invoked, this invariant was broken=20 because there is a pending AIOCB but it is not in dbs->acb. Paolo