I have wfp network filter driver where we receive the packet and do scanning. But it is getting crash while executing ExAllocatePoolWithTag API which is getting call inside spin lock. Below is the code algo-
KeAcquireInStackQueuedSpinLockAtDpcLevel(&g_QLock, &LockHandle);
while(some condition)
{
ExAllocatePoolWithTag(); //////////////crashing here
}
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
It does not crash everytime, in some scenarios it crashes while allocating memory. Below is the crash dump output.
DPC_WATCHDOG_VIOLATION (133)
The DPC watchdog detected a prolonged run time at an IRQL of DISPATCH_LEVEL
or above.
Arguments:
Arg1: 0000000000000000, A single DPC or ISR exceeded its time allotment. The offending
component can usually be identified with a stack trace.
Arg2: 0000000000000501, The DPC time count (in ticks).
Arg3: 0000000000000500, The DPC time allotment (in ticks).
Arg4: fffff80674b74380, cast to nt!DPC_WATCHDOG_GLOBAL_TRIAGE_BLOCK, which contains
additional information regarding this single DPC timeout
DPC_TIMEOUT_TYPE: SINGLE_DPC_TIMEOUT_EXCEEDED
STACK_TEXT:
ffffe181978faba8 fffff803
6389c867 : 0000000000000133 00000000
00000000 0000000000000501 00000000
00000500 : nt!KeBugCheckEx
ffffe181978fabb0 fffff803
63711a4f : 00155db9219a5b70 ffffe181
97900180 0000000000000286 00000000
00069184 : nt!KeAccumulateTicks+0x1877a7
ffffe181978fac10 fffff803
6360447c : 0000000000000000 ffffa48e
1ace0400 ffffa30e9bcfc900 ffffa48e
1ace04b0 : nt!KeClockInterruptNotify+0xcf
ffffe181978faf30 fffff803
6377ca15 : ffffa48e1ace0400 00000000
00000000 0000000000000001 ffff5554
f24cbd06 : hal!HalpTimerClockIpiRoutine+0x1c
ffffe181978faf60 fffff803
6384ba3a : ffffa30e9bcfc900 ffffa48e
1ace0400 0000000000000000 00000000
00000000 : nt!KiCallInterruptServiceRoutine+0xa5
ffffe181978fafb0 fffff803
6384bf87 : 0000000000000000 00000000
00000000 ffffa48e56392000 fffff803
6379b9d8 : nt!KiInterruptSubDispatchNoLockNoEtw+0xfa
ffffa30e9bcfc880 fffff803
637525c3 : ffffa48e1a602300 ffffa48e
1a6028c0 ffffa48e1a602000 00000000
00000030 : nt!KiInterruptDispatchNoLockNoEtw+0x37
ffffa30e9bcfca10 fffff803
639e69bd : 0000000000000002 ffffa30e
9bcfcb69 0000000000000200 00000000
73706d74 : nt!ExAllocateHeapPool+0xca3
ffffa30e9bcfcaf0 fffff802
ec2916d5 : 0000000000000dab 00000000
00000270 ffffa48e55d02000 00000000
00000000 : nt!ExAllocatePoolWithTag+0x3d
ffffa30e9bcfcbd0 fffff802
ec2943d2 : ffffa48e544eb6b8 ffffac88
b8eb2000 ffffa48e5528e000 00000000
00000004 : MyDrvr!Function1+0x1b9
ffffa30e9bcfcc50 fffff802
ec296562 : ffffa48e544eb601 ffffa48e
00000004 ffffa48e5528e000 00000000
00000001 : MyDrvr!Function2+0x262
ffffa30e9bcfcd40 fffff802
ec293a43 : ffffa48e544eb6b8 ffffa48e
544eb6b8 0000000000000001 ffffa30e
9bcfd100 : MyDrvr!Function3+0x8e
ffffa30e9bcfcd70 fffff802
ec296e43 : ffffa30e9bcfd100 ffffa30e
9bcfd100 ffffa30e9bcfd100 ffffa48e
1b5c9300 : MyDrvr!Function4+0x162b
ffffa30e9bcfce50 fffff802
ec29c3db : fffff802ec2ab410 ffffa48e
5528e000 0000000000000001 00000000
00000000 : MyDrvr!Function5+0x8b3
ffffa30e9bcfd0a0 fffff802
ec29afe2 : ffffa48e1b984b00 ffffa48e
54246590 0000000000000004 00000000
00140015 : MyDrvr!Function6+0x7bf
ffffa30e9bcfd2d0 fffff802
ec2744d8 : 0000000000000000 00000000
00000001 0000000000000001 ffffa48e
1b984b00 : MyDrvr!Function7+0x16
And because thread is stuck at ExAllocatePoolWithTag api, spin lock is not getting acquired for new threads. In dump, current irql is 13 but our driver should run on dispatch level or lower. I know because of irql 13. ExAllcatePool and ndisAcquire lock will fail but no idea who is setting irql 13.
What could be the reason of this irql being set in between? Any help here would be appreciated. Thanks in advance.