]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD: fix null pointer access and race condition 6916/head
authorxiexingguo <258156334@qq.com>
Mon, 14 Dec 2015 07:42:38 +0000 (15:42 +0800)
committerxiexingguo <xie.xingguo@zte.com.cn>
Thu, 17 Dec 2015 07:10:19 +0000 (15:10 +0800)
We are risking of accessing a null osdmap pointer when we failed to handle an osdmap message due to network error.
Also, it is not safe to change failure_pending without protection of hearbeat_lock.

Fixes: #14072
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/osd/OSD.cc

index 1d0ca9c57f21e0dcaa17f6742506227b359ef3f7..f38695ab74a58b70aa5385576958794f459a33ee 100644 (file)
@@ -6633,16 +6633,17 @@ void OSD::handle_osd_map(MOSDMap *m)
     osdmap_subscribe(osdmap->get_epoch()+1, false);
   }
   else if (do_shutdown) {
-    osd_lock.Unlock();
-    shutdown();
     if (network_error) {
+      Mutex::Locker l(heartbeat_lock); 
       map<int,pair<utime_t,entity_inst_t>>::iterator it = failure_pending.begin();
       while (it != failure_pending.end()) {
         dout(10) << "handle_osd_ping canceling in-flight failure report for osd." << it->first << dendl;
         send_still_alive(osdmap->get_epoch(), it->second.second);
         failure_pending.erase(it++);
       }
-    }
+    }  
+    osd_lock.Unlock();
+    shutdown();
     osd_lock.Lock();
   }
   else if (is_preboot()) {