]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephfs: Fixed a bug in the readdir_cache_cb function that may have used freed memory...
authorchentao.2022 <chentao.2022@bytedance.com>
Mon, 24 Jun 2024 03:23:27 +0000 (11:23 +0800)
committerXiubo Li <xiubli@redhat.com>
Thu, 25 Jul 2024 02:07:45 +0000 (10:07 +0800)
Fixes: https://tracker.ceph.com/issues/56288
Signed-off-by: Tod Chen <chentao.2022@bytedance.com>
(cherry picked from commit a71c9dd7e57a6a1dd64ccfb67f24c2a7cf29f652

src/client/Client.cc

index a84e69f38f2fdcca7691a0c805b6d27a0398a924..571ecd463f070da9511a6b172bd7ed42aa9cac56 100644 (file)
@@ -9382,6 +9382,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;