From: Sage Weil Date: Thu, 25 May 2017 22:25:27 +0000 (-0400) Subject: mgr/MgrStandby: prevent use-after-free on just-shut-down Mgr X-Git-Tag: v12.1.0~57^2~19^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F15297%2Fhead;p=ceph.git mgr/MgrStandby: prevent use-after-free on just-shut-down Mgr Fixes: http://tracker.ceph.com/issues/19595 Signed-off-by: Sage Weil --- diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc index 1bfcadd71b45b..bc946e41c18c9 100644 --- a/src/mgr/MgrStandby.cc +++ b/src/mgr/MgrStandby.cc @@ -258,8 +258,9 @@ bool MgrStandby::ms_dispatch(Message *m) default: if (active_mgr) { + auto am = active_mgr; lock.Unlock(); - active_mgr->ms_dispatch(m); + am->ms_dispatch(m); lock.Lock(); } else { return false; diff --git a/src/mgr/MgrStandby.h b/src/mgr/MgrStandby.h index d33c633dc424e..b60d591018ea7 100644 --- a/src/mgr/MgrStandby.h +++ b/src/mgr/MgrStandby.h @@ -53,7 +53,7 @@ protected: Mutex lock; SafeTimer timer; - std::unique_ptr active_mgr; + std::shared_ptr active_mgr; std::string state_str();