]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs: Fixed a bug in the readdir_cache_cb function that may have used freed memory... 58804/head
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:03:15 +0000 (10:03 +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 5bc050e97b5de74e7682edfbc7d2d4118f0a3947..6d5d2ded8575779c5b2ee8eafdca635fcc922f52 100644 (file)
@@ -9398,6 +9398,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;