Skip to content

Commit

Permalink
xen/blkback: don't free be structure too early
Browse files Browse the repository at this point in the history
The be structure must not be freed when freeing the blkif structure
isn't done. Otherwise a use-after-free of be when unmapping the ring
used for communicating with the frontend will occur in case of a
late call of xenblk_disconnect() (e.g. due to an I/O still active
when trying to disconnect).

Signed-off-by: Juergen Gross <jgross@suse.com>
Tested-by: Steven Haigh <netwiz@crc.id.au>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Juergen Gross authored and Konrad Rzeszutek Wilk committed Jun 13, 2017
1 parent 4646441 commit 71df1d7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/block/xen-blkback/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,10 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)

static void xen_blkif_free(struct xen_blkif *blkif)
{

xen_blkif_disconnect(blkif);
WARN_ON(xen_blkif_disconnect(blkif));
xen_vbd_free(&blkif->vbd);
kfree(blkif->be->mode);
kfree(blkif->be);

/* Make sure everything is drained before shutting down */
kmem_cache_free(xen_blkif_cachep, blkif);
Expand Down Expand Up @@ -514,8 +515,6 @@ static int xen_blkbk_remove(struct xenbus_device *dev)
xen_blkif_put(be->blkif);
}

kfree(be->mode);
kfree(be);
return 0;
}

Expand Down

0 comments on commit 71df1d7

Please sign in to comment.