[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [RHEL-7.2.z qemu-kvm-rhev PATCH] virtio-blk: Fix double
From: |
Fam Zheng |
Subject: |
Re: [Qemu-block] [RHEL-7.2.z qemu-kvm-rhev PATCH] virtio-blk: Fix double completion for werror=stop |
Date: |
Mon, 23 Nov 2015 08:31:34 +0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, 11/18 11:19, Fam Zheng wrote:
> BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1277922
> Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=10113752
>
> When a request R is absorbed by request M, it is appended to the
> "mr_next" queue led by M, and is completed together with the completion
> of M, in virtio_blk_rw_complete.
>
> During DMA restart in virtio_blk_dma_restart_bh, requests in s->rq are
> parsed and submitted again, possibly with a stale req->mr_next. It could
> be a problem if the request merging in virtio_blk_handle_request hasn't
> refreshed every mr_next pointer, in which case, virtio_blk_rw_complete
> could walk through unexpected requests following the stale pointers.
>
> Fix this by unsetting the pointer in virtio_blk_rw_complete. It is safe
> because this req is either completed and freed right away, or it will be
> restarted and parsed from scratch out of the vq later.
>
> Signed-off-by: Fam Zheng <address@hidden>
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> (cherry picked from commit 10f5a72f70862d299ddbdf226d6dc71fa4ae34dd)
> Signed-off-by: Fam Zheng <address@hidden>
> ---
> hw/block/virtio-blk.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index f9301ae..fe146ad 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -112,6 +112,10 @@ static void virtio_blk_rw_complete(void *opaque, int ret)
> * happen on the other side of the migration).
> */
> if (virtio_blk_handle_rw_error(req, -ret, is_read)) {
> + /* Break the link in case the next request is added to the
> + * restart queue and is going to be parsed from the ring
> again.
> + */
> + req->mr_next = NULL;
Paolo pointed out this is a write-after-free with error=report, will need to
respin after fixing upstream.
NACK
> continue;
> }
> }
> --
> 2.4.3
>