aboutsummaryrefslogtreecommitdiffstats
path: root/wintun.c
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-06-12 22:10:37 +0200
committerSimon Rozman <simon@rozman.si>2019-06-20 11:54:57 +0200
commit70fcfdc85d2480e7f2dea4fce364a19548e0f12f (patch)
treefc69adfc5741dc4a911b7882fdd930476396a12a /wintun.c
parentRevise adapter state checking (diff)
downloadwintun-70fcfdc85d2480e7f2dea4fce364a19548e0f12f.tar.xz
wintun-70fcfdc85d2480e7f2dea4fce364a19548e0f12f.zip
Add missing state transition lock
When we are transitioning to a state that suspends some operations, we must get an exclusive transition lock to wait for all operations that have a shared transition lock. And TunHaltEx() is no exception. Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to '')
-rw-r--r--wintun.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/wintun.c b/wintun.c
index 46d4d2f..3f1b6cf 100644
--- a/wintun.c
+++ b/wintun.c
@@ -1332,7 +1332,9 @@ static void TunHaltEx(NDIS_HANDLE MiniportAdapterContext, NDIS_HALT_ACTION HaltA
ASSERT(!ctx->PnPNotifications.Handle);
ASSERT(!InterlockedGet64(&ctx->ActiveTransactionCount)); /* Adapter should not be halted if it wasn't fully paused first. */
+ KIRQL irql = ExAcquireSpinLockExclusive(&ctx->TransitionLock);
InterlockedAnd(&ctx->Flags, ~TUN_FLAGS_PRESENT);
+ ExReleaseSpinLockExclusive(&ctx->TransitionLock, irql);
for (IRP *pending_irp; (pending_irp = IoCsqRemoveNextIrp(&ctx->Device.ReadQueue.Csq, NULL)) != NULL;)
TunCompleteRequest(ctx, pending_irp, STATUS_FILE_FORCED_CLOSED, IO_NO_INCREMENT);