From 80d5dcb4c6a4b2e5d6079dfb62d86b37326b6cc4 Mon Sep 17 00:00:00 2001 From: Aliaksei Makarau Date: Tue, 31 May 2022 09:24:19 +0200 Subject: [PATCH] mds/fsmap: proper update of filesystems Segfault was triggered by the fs/multifs test. The problem is in potential undefined behaviour afer erasing element and iterator invalidation in FSMap::stop() and FSMap::erase(). Fixed by decoupling element removal from the loop. Fixes: https://tracker.ceph.com/issues/55620 Signed-off-by: Aliaksei Makarau --- src/mds/FSMap.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index 217a1e3307c54..b9ae05ac0f622 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -1090,10 +1090,13 @@ std::vector FSMap::stop(mds_gid_t who) if (other_info.rank == info.rank && other_info.state == MDSMap::STATE_STANDBY_REPLAY) { standbys.push_back(other_gid); - erase(other_gid, 0); } } + for (const auto &other_gid : standbys) { + erase(other_gid, 0); + } + fs->mds_map.mds_info.erase(who); mds_roles.erase(who); -- 2.39.5