diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-07-31 14:10:37 +0000 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-08-02 09:43:32 +0000 |
commit | a2d46f3c00763dbb7eb2a4917336cd08d1f93a87 (patch) | |
tree | 1a99d4719cdbe738201e9f03a663a8a15a733765 | |
parent | Unify driver input file list (diff) | |
download | wintun-a2d46f3c00763dbb7eb2a4917336cd08d1f93a87.tar.xz wintun-a2d46f3c00763dbb7eb2a4917336cd08d1f93a87.zip |
Disable APC when taking rwlock
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | wintun.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -835,6 +835,7 @@ TunDispatchDeviceControl(DEVICE_OBJECT *DeviceObject, IRP *Irp) switch (Stack->Parameters.DeviceIoControl.IoControlCode) { case TUN_IOCTL_REGISTER_RINGS: { + KeEnterCriticalRegion(); ExAcquireResourceSharedLite(&TunDispatchCtxGuard, TRUE); #pragma warning(suppress : 28175) TUN_CTX *Ctx = DeviceObject->Reserved; @@ -842,6 +843,7 @@ TunDispatchDeviceControl(DEVICE_OBJECT *DeviceObject, IRP *Irp) if (Ctx) Status = TunRegisterBuffers(Ctx, Irp); ExReleaseResourceLite(&TunDispatchCtxGuard); + KeLeaveCriticalRegion(); break; } case TUN_IOCTL_FORCE_CLOSE_HANDLES: @@ -862,12 +864,14 @@ _Use_decl_annotations_ static NTSTATUS TunDispatchClose(DEVICE_OBJECT *DeviceObject, IRP *Irp) { + KeEnterCriticalRegion(); ExAcquireResourceSharedLite(&TunDispatchCtxGuard, TRUE); #pragma warning(suppress : 28175) TUN_CTX *Ctx = DeviceObject->Reserved; if (Ctx) TunUnregisterBuffers(Ctx, IoGetCurrentIrpStackLocation(Irp)->FileObject); ExReleaseResourceLite(&TunDispatchCtxGuard); + KeLeaveCriticalRegion(); return NdisDispatchClose(DeviceObject, Irp); } @@ -1083,8 +1087,10 @@ TunHaltEx(NDIS_HANDLE MiniportAdapterContext, NDIS_HALT_ACTION HaltAction) InterlockedSetPointer(&Ctx->MiniportAdapterHandle, NULL); #pragma warning(suppress : 28175) InterlockedSetPointer(&Ctx->FunctionalDeviceObject->Reserved, NULL); + KeEnterCriticalRegion(); ExAcquireResourceExclusiveLite(&TunDispatchCtxGuard, TRUE); /* Ensure above change is visible to all readers. */ ExReleaseResourceLite(&TunDispatchCtxGuard); + KeLeaveCriticalRegion(); ExFreePoolWithTag(Ctx, TUN_MEMORY_TAG); } |