]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Protect BackendPath from race using StateLock
authorBen Chalmers <Ben.Chalmers@citrix.com>
Tue, 20 Jan 2015 14:27:19 +0000 (14:27 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 20 Jan 2015 14:36:36 +0000 (14:36 +0000)
The BackendPath can change as part of PDO state transitions, leading
to a race with the frontend thread.  Since the frontend state lock is
locked through state transitions, taking the lock is sufficient to
avoid the race

Signed-off-by: Ben Chalmers <Ben.Chalmers@citrix.com>
src/xenvbd/frontend.c

index 25b268dc5187dcf0fbe8231ccb085cd4b4879699..f01b14208113e01f22ae5f0963b3a96d85374136 100644 (file)
@@ -1579,12 +1579,15 @@ FrontendBackendPathChanged(
     __in  PXENVBD_FRONTEND        Frontend
     )
 {
+    KIRQL       Irql;
+    KeAcquireSpinLock(&Frontend->StateLock, &Irql);
     // Only attempt this if Active, Active is set/cleared on D3->D0/D0->D3
     if (Frontend->Active) {
         // Note: Nothing may have changed with this target, this could be caused by another target changing
         __ReadDiskInfo(Frontend);
         __CheckBackendForEject(Frontend);
     }
+    KeReleaseSpinLock(&Frontend->StateLock, Irql);
 }
 
 __checkReturn