]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file.h: fix potential data race condition
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 21 Feb 2017 12:55:40 +0000 (13:55 +0100)
committerKefu Chai <kchai@redhat.com>
Mon, 10 Apr 2017 10:16:17 +0000 (18:16 +0800)
Fix for:

CID 1399581 (#1 of 1): Data race condition (MISSING_LOCK)
 missing_lock: Accessing this->state.atime without holding lock
 rgw::RGWFileHandle.mtx. Elsewhere, "_ZN3rgw13RGWFileHandle5StateE.atime"
 is accessed with rgw::RGWFileHandle.mtx held 2 out of 3 times
 (2 of these accesses strongly imply that it is necessary).

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/rgw/rgw_file.h

index 3d671a0dee2f853c5441b17071ac4de907e960bb..42439bedf95482b1c93379167f61f9d3b7537d94 100644 (file)
@@ -534,6 +534,7 @@ namespace rgw {
     }
 
     void set_times(real_time t) {
+      lock_guard guard(mtx);
       state.ctime = real_clock::to_timespec(t);
       state.mtime = state.ctime;
       state.atime = state.ctime;