Commit 313d7b00 authored by Keir Fraser's avatar Keir Fraser Committed by Konrad Rzeszutek Wilk

blkback: Fix CVE-2010-3699

A guest can cause the backend driver to leak a kernel thread. Such
leaked threads hold references to the device, whichmakes the device
impossible to tear down. If shut down, the guest remains a zombie
domain, the xenwatch process hangs, and most xm commands will stop
working.

This patch tries to do the following for blkback:
    - identify/extract idempotent teardown operations,
    - add/move the invocation of said teardown operation
      right before we're about to allocate new resources in the
      Connected states.

[ linux-2.6.18-xen.hg 59f097ef181b ]
Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
Signed-off-by: default avatarKeir Fraser <keir@xen.org>
Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
parent a81135d9
...@@ -382,6 +382,11 @@ static void frontend_changed(struct xenbus_device *dev, ...@@ -382,6 +382,11 @@ static void frontend_changed(struct xenbus_device *dev,
if (dev->state == XenbusStateConnected) if (dev->state == XenbusStateConnected)
break; break;
/* Enforce precondition before potential leak point.
* blkif_disconnect() is idempotent.
*/
blkif_disconnect(be->blkif);
err = connect_ring(be); err = connect_ring(be);
if (err) if (err)
break; break;
...@@ -399,6 +404,7 @@ static void frontend_changed(struct xenbus_device *dev, ...@@ -399,6 +404,7 @@ static void frontend_changed(struct xenbus_device *dev,
break; break;
/* fall through if not online */ /* fall through if not online */
case XenbusStateUnknown: case XenbusStateUnknown:
/* implies blkif_disconnect() via blkback_remove() */
device_unregister(&dev->dev); device_unregister(&dev->dev);
break; break;
......
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