Josh Durgin 9875201e10 rbd: fix use-after free of rbd_dev->disk
Removing a device deallocates the disk, unschedules the watch, and
finally cleans up the rbd_dev structure. rbd_dev_refresh(), called
from the watch callback, updates the disk size and rbd_dev
structure. With no locking between them, rbd_dev_refresh() may use the
device or rbd_dev after they've been freed.

To fix this, check whether RBD_DEV_FLAG_REMOVING is set before
updating the disk size in rbd_dev_refresh(). In order to prevent a
race where rbd_dev_refresh() is already revalidating the disk when
rbd_remove() is called, move the call to rbd_bus_del_dev() after the
watch is unregistered and all notifies are complete. It's safe to
defer deleting this structure because no new requests can be submitted
once the RBD_DEV_FLAG_REMOVING is set, since the device cannot be
opened.

Fixes: http://tracker.ceph.com/issues/5636
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2013-09-09 11:16:25 -07:00
..
2013-06-19 13:52:10 +02:00
2013-04-09 14:13:19 -04:00
2013-06-12 16:29:45 -07:00
2013-04-09 14:13:32 -04:00
2012-03-28 18:30:03 +01:00
2013-06-29 12:46:45 +04:00
2013-06-29 12:46:45 +04:00
2013-03-28 14:50:49 -04:00
2013-07-03 16:08:05 -07:00
2013-05-31 11:45:52 -04:00
2013-04-09 14:13:32 -04:00
2013-09-09 11:16:25 -07:00