Commit c4ed418d authored by Juergen Gross's avatar Juergen Gross Committed by Greg Kroah-Hartman

xen/blkback: don't free be structure too early

commit 71df1d7c upstream.

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: default avatarJuergen Gross <jgross@suse.com>
Tested-by: default avatarSteven Haigh <netwiz@crc.id.au>
Acked-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f21d9eda
...@@ -315,8 +315,10 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif) ...@@ -315,8 +315,10 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
static void xen_blkif_free(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); xen_vbd_free(&blkif->vbd);
kfree(blkif->be->mode);
kfree(blkif->be);
/* Make sure everything is drained before shutting down */ /* Make sure everything is drained before shutting down */
kmem_cache_free(xen_blkif_cachep, blkif); kmem_cache_free(xen_blkif_cachep, blkif);
...@@ -511,8 +513,6 @@ static int xen_blkbk_remove(struct xenbus_device *dev) ...@@ -511,8 +513,6 @@ static int xen_blkbk_remove(struct xenbus_device *dev)
/* Put the reference we set in xen_blkif_alloc(). */ /* Put the reference we set in xen_blkif_alloc(). */
xen_blkif_put(be->blkif); xen_blkif_put(be->blkif);
kfree(be->mode);
kfree(be);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment