]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commit
client: crash caused by invalid iterator in _readdir_cache_cb
authorZhansong Gao <zhsgao@hotmail.com>
Wed, 23 Jul 2025 05:37:39 +0000 (13:37 +0800)
committerJos Collin <jcollin@redhat.com>
Thu, 16 Oct 2025 06:10:01 +0000 (11:40 +0530)
commit7b795a2d47a5d21e67c87da039c99b5e802de495
tree7286ee6b106af12c5a97c3cfef980863951148cb
parent321af4c3eea1fbfa6064ee984e2bf1dd2948d008
client: crash caused by invalid iterator in _readdir_cache_cb

Capacity of `readdir_cache` may change after `client_lock` is unlocked in iterations of `readdir_cache`,
and it can cause the iterator to be invalid, then using the invalid iterator in the next iteration will cause crash.
Crash may happen at `Dentry *dn = *pd` (pd points to invalid memory),
or at `if (pd >= dir->readdir_cache.end() || *pd != dn)` (pd is smaller than begin() if idx is negative).
Use index instead of iterator to solve this problem.

Fixes: https://tracker.ceph.com/issues/72247
Signed-off-by: Zhansong Gao <zhsgao@hotmail.com>
(cherry picked from commit 9e0488dd0bda18ab2abd96cdb3ec18034c1e85f1)
src/client/Client.cc