Disable APC when taking rwlock
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		
							parent
							
								
									ac3576a57e
								
							
						
					
					
						commit
						a2d46f3c00
					
				
							
								
								
									
										6
									
								
								wintun.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								wintun.c
									
									
									
									
									
								
							| @ -835,6 +835,7 @@ TunDispatchDeviceControl(DEVICE_OBJECT *DeviceObject, IRP *Irp) | |||||||
|     switch (Stack->Parameters.DeviceIoControl.IoControlCode) |     switch (Stack->Parameters.DeviceIoControl.IoControlCode) | ||||||
|     { |     { | ||||||
|     case TUN_IOCTL_REGISTER_RINGS: { |     case TUN_IOCTL_REGISTER_RINGS: { | ||||||
|  |         KeEnterCriticalRegion(); | ||||||
|         ExAcquireResourceSharedLite(&TunDispatchCtxGuard, TRUE); |         ExAcquireResourceSharedLite(&TunDispatchCtxGuard, TRUE); | ||||||
| #pragma warning(suppress : 28175) | #pragma warning(suppress : 28175) | ||||||
|         TUN_CTX *Ctx = DeviceObject->Reserved; |         TUN_CTX *Ctx = DeviceObject->Reserved; | ||||||
| @ -842,6 +843,7 @@ TunDispatchDeviceControl(DEVICE_OBJECT *DeviceObject, IRP *Irp) | |||||||
|         if (Ctx) |         if (Ctx) | ||||||
|             Status = TunRegisterBuffers(Ctx, Irp); |             Status = TunRegisterBuffers(Ctx, Irp); | ||||||
|         ExReleaseResourceLite(&TunDispatchCtxGuard); |         ExReleaseResourceLite(&TunDispatchCtxGuard); | ||||||
|  |         KeLeaveCriticalRegion(); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|     case TUN_IOCTL_FORCE_CLOSE_HANDLES: |     case TUN_IOCTL_FORCE_CLOSE_HANDLES: | ||||||
| @ -862,12 +864,14 @@ _Use_decl_annotations_ | |||||||
| static NTSTATUS | static NTSTATUS | ||||||
| TunDispatchClose(DEVICE_OBJECT *DeviceObject, IRP *Irp) | TunDispatchClose(DEVICE_OBJECT *DeviceObject, IRP *Irp) | ||||||
| { | { | ||||||
|  |     KeEnterCriticalRegion(); | ||||||
|     ExAcquireResourceSharedLite(&TunDispatchCtxGuard, TRUE); |     ExAcquireResourceSharedLite(&TunDispatchCtxGuard, TRUE); | ||||||
| #pragma warning(suppress : 28175) | #pragma warning(suppress : 28175) | ||||||
|     TUN_CTX *Ctx = DeviceObject->Reserved; |     TUN_CTX *Ctx = DeviceObject->Reserved; | ||||||
|     if (Ctx) |     if (Ctx) | ||||||
|         TunUnregisterBuffers(Ctx, IoGetCurrentIrpStackLocation(Irp)->FileObject); |         TunUnregisterBuffers(Ctx, IoGetCurrentIrpStackLocation(Irp)->FileObject); | ||||||
|     ExReleaseResourceLite(&TunDispatchCtxGuard); |     ExReleaseResourceLite(&TunDispatchCtxGuard); | ||||||
|  |     KeLeaveCriticalRegion(); | ||||||
|     return NdisDispatchClose(DeviceObject, Irp); |     return NdisDispatchClose(DeviceObject, Irp); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -1083,8 +1087,10 @@ TunHaltEx(NDIS_HANDLE MiniportAdapterContext, NDIS_HALT_ACTION HaltAction) | |||||||
|     InterlockedSetPointer(&Ctx->MiniportAdapterHandle, NULL); |     InterlockedSetPointer(&Ctx->MiniportAdapterHandle, NULL); | ||||||
| #pragma warning(suppress : 28175) | #pragma warning(suppress : 28175) | ||||||
|     InterlockedSetPointer(&Ctx->FunctionalDeviceObject->Reserved, NULL); |     InterlockedSetPointer(&Ctx->FunctionalDeviceObject->Reserved, NULL); | ||||||
|  |     KeEnterCriticalRegion(); | ||||||
|     ExAcquireResourceExclusiveLite(&TunDispatchCtxGuard, TRUE); /* Ensure above change is visible to all readers. */ |     ExAcquireResourceExclusiveLite(&TunDispatchCtxGuard, TRUE); /* Ensure above change is visible to all readers. */ | ||||||
|     ExReleaseResourceLite(&TunDispatchCtxGuard); |     ExReleaseResourceLite(&TunDispatchCtxGuard); | ||||||
|  |     KeLeaveCriticalRegion(); | ||||||
|     ExFreePoolWithTag(Ctx, TUN_MEMORY_TAG); |     ExFreePoolWithTag(Ctx, TUN_MEMORY_TAG); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user