]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/KernelDevice: avoid possible use-after-free for ioc->priv
authorSage Weil <sage@redhat.com>
Mon, 23 Jan 2017 19:46:34 +0000 (14:46 -0500)
committerSage Weil <sage@redhat.com>
Fri, 27 Jan 2017 15:26:16 +0000 (10:26 -0500)
If aio_wake() triggers destruction, ioc->priv might be a
use-after-free (this is the case for the BlueStore read path).

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/KernelDevice.cc

index c9cde7868e305a49cea86b2f83a02a5f27765ced..7ffd6fd91f7b1876a43a5ae415fd5922a30cd269 100644 (file)
@@ -269,10 +269,12 @@ void KernelDevice::_aio_thread()
        // trust aio[] values; they my be freed (e.g., by BlueFS::_fsync)
        if (left == 0) {
          // check waiting count before doing callback (which may
-         // destroy this ioc).
+         // destroy this ioc).  and avoid ref to ioc after aio_wake()
+         // in case that triggers destruction.
+         void *priv = ioc->priv;
          ioc->aio_wake();
-         if (ioc->priv) {
-           aio_callback(aio_callback_priv, ioc->priv);
+         if (priv) {
+           aio_callback(aio_callback_priv, priv);
          }
        }
       }