Skip to content

Commit a71c9dd

Browse files
author
chentao.2022
committed
cephfs: Fixed a bug in the readdir_cache_cb function that may have used freed memory after the _getattr operation returned
Fixes: https://tracker.ceph.com/issues/56288 Signed-off-by: Tod Chen <[email protected]>
1 parent 1e7a753 commit a71c9dd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/client/Client.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9405,6 +9405,12 @@ int Client::_readdir_cache_cb(dir_result_t *dirp, add_dirent_cb_t cb, void *p,
94059405
int r = _getattr(dn->inode, mask, dirp->perms);
94069406
if (r < 0)
94079407
return r;
9408+
9409+
/* fix https://tracker.ceph.com/issues/56288 */
9410+
if (dirp->inode->dir == NULL) {
9411+
ldout(cct, 0) << " dir is closed, so we should return" << dendl;
9412+
return -CEPHFS_EAGAIN;
9413+
}
94089414

94099415
// the content of readdir_cache may change after _getattr(), so pd may be invalid iterator
94109416
pd = dir->readdir_cache.begin() + idx;

0 commit comments

Comments
 (0)