]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix use-after-free in Client::link() 22611/head
authorYan, Zheng <zyan@redhat.com>
Tue, 19 Jun 2018 02:39:19 +0000 (10:39 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 19 Jun 2018 02:39:19 +0000 (10:39 +0800)
Fixes: http://tracker.ceph.com/issues/24557
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/client/Client.cc

index 213b78465d4f83cf3a06ab9f44e6bea5330276cd..1b2a209c5cc02beb42971a26359fbc09ee4cd9a7 100644 (file)
@@ -2975,8 +2975,10 @@ Dentry* Client::link(Dir *dir, const string& name, Inode *in, Dentry *dn)
   }
 
   if (in) {    // link to inode
+    InodeRef tmp_ref;
     // only one parent for directories!
     if (in->is_dir() && !in->dentries.empty()) {
+      tmp_ref = in; // prevent unlink below from freeing the inode.
       Dentry *olddn = in->get_first_parent();
       assert(olddn->dir != dir || olddn->name != name);
       Inode *old_diri = olddn->dir->parent_inode;