From: Patrick Donnelly Date: Tue, 12 Oct 2021 18:00:50 +0000 (-0400) Subject: mon/MDSMonitor: avoid crash when decoding old FSMap epochs X-Git-Tag: v16.2.7~68^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F43615%2Fhead;p=ceph.git mon/MDSMonitor: avoid crash when decoding old FSMap epochs Fixes: https://tracker.ceph.com/issues/52820 Signed-off-by: Patrick Donnelly (cherry picked from commit 631360a41ab2ad93445d35a9730200beef2bebab) --- diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index 9508e8df2c9e..9be570e537a7 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -641,6 +641,7 @@ void FSMap::encode(bufferlist& bl, uint64_t features) const void FSMap::decode(bufferlist::const_iterator& p) { + struct_version = 0; DECODE_START(STRUCT_VERSION, p); DECODE_OLDEST(7); struct_version = struct_v; diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 419447befa42..ac2bd2d15759 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -2306,7 +2306,12 @@ void MDSMonitor::tick() derr << "could not get version " << v << dendl; ceph_abort(); } - fsmap.decode(bl); + try { + fsmap.decode(bl); + } catch (const ceph::buffer::malformed_input& e) { + dout(5) << "flushing old fsmap struct because unable to decode FSMap: " << e.what() << dendl; + } + /* N.B. FSMap::is_struct_old is also true for undecoded (failed to decode) FSMap */ if (fsmap.is_struct_old()) { dout(5) << "fsmap struct is too old; proposing to flush out old versions" << dendl; do_propose = true;