From: Brad Hubbard Date: Fri, 27 Nov 2020 00:55:54 +0000 (+1000) Subject: mon: paxos: Delete logger in destructor X-Git-Tag: v14.2.17~38^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F39160%2Fhead;p=ceph.git mon: paxos: Delete logger in destructor reset() can race with shutdown() leading to a use-after-free on the 'logger' object. Fixes: https://tracker.ceph.com/issues/48386 Signed-off-by: Brad Hubbard (cherry picked from commit cc295d1c87552eb76b9188d88d7e6ab2f3108149) Conflicts: src/mon/Paxos.h - stable branch has slightly different Paxos and get_name function declarations --- diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 3a691931c9f2..a62b028b57fe 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -1332,7 +1332,6 @@ void Paxos::shutdown() finish_contexts(g_ceph_context, committing_finishers, -ECANCELED); if (logger) g_ceph_context->get_perfcounters_collection()->remove(logger); - delete logger; } void Paxos::leader_init() diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index 590279ed9cef..75bac47223f7 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -1045,7 +1045,7 @@ public: * @param name A name for the paxos service. It serves as the naming space * of the underlying persistent storage for this service. */ - Paxos(Monitor *m, const string &name) + Paxos(Monitor *m, const string &name) : mon(m), logger(NULL), paxos_name(name), @@ -1065,6 +1065,10 @@ public: clock_drift_warned(0), trimming(false) { } + ~Paxos() { + delete logger; + } + const string get_name() const { return paxos_name; }