]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs: Fixed a bug in the readdir_cache_cb function that may have used freed... 58216/head
authorchentao.2022 <chentao.2022@bytedance.com>
Mon, 24 Jun 2024 03:23:27 +0000 (11:23 +0800)
committerchentao.2022 <chentao.2022@bytedance.com>
Mon, 24 Jun 2024 05:16:18 +0000 (13:16 +0800)
Fixes: https://tracker.ceph.com/issues/56288
Signed-off-by: Tod Chen <chentao.2022@bytedance.com>
src/client/Client.cc

index fffbd11f600784000aaabc6fec5c080ea3ec77fd..1887b0fce1fc1bc5e7a50e108e015d4121ee32e7 100644 (file)
@@ -9405,6 +9405,12 @@ int Client::_readdir_cache_cb(dir_result_t *dirp, add_dirent_cb_t cb, void *p,
     int r = _getattr(dn->inode, mask, dirp->perms);
     if (r < 0)
       return r;
+
+    /* fix https://tracker.ceph.com/issues/56288 */
+    if (dirp->inode->dir == NULL) {
+      ldout(cct, 0) << " dir is closed, so we should return" << dendl;
+      return -CEPHFS_EAGAIN;
+    }
     
     // the content of readdir_cache may change after _getattr(), so pd may be invalid iterator    
     pd = dir->readdir_cache.begin() + idx;