From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org
Cc: konrad.wilk@oracle.com, roger.pau@citrix.com, netwiz@crc.id.au,
Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 2/3] xen/blkback: don't free be structure too early
Date: Thu, 18 May 2017 17:28:48 +0200 [thread overview]
Message-ID: <20170518152849.1872-3-jgross@suse.com> (raw)
In-Reply-To: <20170518152849.1872-1-jgross@suse.com>
The be structure must nor 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>
---
drivers/block/xen-blkback/xenbus.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 998915174bb8..4cdf0490983e 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -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);
@@ -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;
}
--
2.12.0
next prev parent reply other threads:[~2017-05-18 15:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 15:28 [PATCH v2 0/3] xen/blkback: several fixes of resource management Juergen Gross
2017-05-18 15:28 ` [PATCH v2 1/3] xen/blkback: fix disconnect while I/Os in flight Juergen Gross
2017-05-18 15:28 ` Juergen Gross [this message]
2017-05-18 15:28 ` [PATCH v2 3/3] xen/blkback: don't use xen_blkif_get() in xen-blkback kthread Juergen Gross
2017-06-07 12:36 ` [PATCH v2 0/3] xen/blkback: several fixes of resource management Steven Haigh
2017-06-07 13:52 ` [Xen-devel] " Konrad Rzeszutek Wilk
2017-06-07 14:08 ` Steven Haigh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170518152849.1872-3-jgross@suse.com \
--to=jgross@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netwiz@crc.id.au \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox