Hi,
I'm trying to experiment with Driver Verifier's DDI compliance checking and additional compliance checking rules. The docs [1] [2] explain that in Windows 8.1 Preview, Driver Verifier should be able to catch a recursive spinlock acquisition as a violation of DDI compliance rules.
I've modified the Notmyfault application (and driver) with an additional option that causes a deadlock by recursively acquiring a spinlock:
VOID
SpinlockDeadlock(
VOID
)
{
KIRQL OldIrql;
static KSPIN_LOCK SpinLock;
KeInitializeSpinLock( &SpinLock );
// Attemps to acquire a spinlock twice. This is guaranteed to cause
// a deadlock immediately.
KeAcquireSpinLock( &SpinLock, &OldIrql );
KeAcquireSpinLock (&SpinLock, &OldIrql );
KeReleaseSpinLock (&SpinLock, OldIrql );
}
Driver Verifier is enabled for the myfault.sys driver with both DDI compliance checking and additional DDI compliance checking:
kd> !verifier
Verify Level a0000 ... enabled options are:
DDI compliance checking enabled
Also, I can see the load message when myfault.sys is loaded, telling me that the DV rules are in effect.
Nonetheless, DV does not detect the recursive spinlock acquisition and the system just hangs. Here is the call stack from the kernel debugger at the point of the hang (you can see DV's injected frames 08, 09, 0a):
kd> kn
*** Stack trace for last set context - .thread/.cxr resets it
Child-SP RetAddr Call Site
00 fffff8008639bc88 fffff80084997940 nt!DbgBreakPointWithStatus
01 fffff8008639bc90 fffff8008489c9ee nt! ?? ::FNODOBFM::string'+0x23300 02 fffff8008639bd20 fffff80084faaf1f nt!KeClockInterruptNotify+0x73e 03 fffff8008639bf40 fffff800848f5cc2 hal!HalpTimerClockInterrupt+0x4f 04 fffff8008639bf70 fffff8008496522a nt!KiCallInterruptServiceRoutine+0x122 05 fffff8008639bfb0 fffff8008496560f nt!KiInterruptSubDispatchNoLockNoEtw+0xea 06 ffffd0002116f730 fffff800848f5ee0 nt!KiInterruptDispatchLBControl+0x11f 07 ffffd0002116f8c0 fffff800848f5ea2 nt!KxWaitForSpinLockAndAcquire+0x20 08 ffffd0002116f8f0 fffff800002e9559 nt!KeAcquireSpinLockRaiseToDpc+0x32 09 ffffd0002116f920 fffff80084e959cb VerifierExt!KeAcquireSpinLockRaiseToDpc_wrapper+0x129 0a ffffd0002116f970 fffff800025f2385 nt!VerifierKeAcquireSpinLockRaiseToDpc+0x5f 0b ffffd0002116f9b0 fffff800025f24ff myfault!MyfaultDeviceControl+0x351 0c ffffd0002116fb10 fffff80084e825a8 myfault!MyfaultDispatch+0xb7 0d ffffd0002116fb70 fffff80084becbb3 nt!IovCallDriver+0xb4 0e ffffd0002116fbc0 fffff80084beddaa nt!IopXxxControlFile+0x8c3 0f ffffd0002116fd60 fffff8008496f6b3 nt!NtDeviceIoControlFile+0x56 10 ffffd0002116fdd0 00007fff4f53b12a nt!KiSystemServiceCopyEnd+0x13 11 000000000050ef48 00007fff4c962f83 ntdll!NtDeviceIoControlFile+0xa 12 000000000050ef50 00007fff4f3614f0 KERNELBASE!DeviceIoControl+0x73 13 000000000050efc0 00007ff7da59275b KERNEL32!DeviceIoControlImplementation+0x74 14 000000000050f010 00007fff4edd182e NotMyfault!HangDialogProc+0x93 15 000000000050f090 00007fff4edd160c USER32!UserCallDlgProcCheckWow+0x112 16 000000000050f160 00007fff4ee23111 USER32!DefDlgProcWorker+0xb4 17 000000000050f220 00007fff4edc27a4 USER32!DefDlgProcA+0x39 18 000000000050f260 00007fff4edc4372 USER32!UserCallWinProcCheckWow+0x140 19 000000000050f320 00007fff4edc443d USER32!DispatchClientMessage+0xa2 1a 000000000050f380 00007fff4f53cecf USER32!_fnDWORD+0x2d 1b 000000000050f3e0 00007fff4edc1fca ntdll!KiUserCallbackDispatcherContinue 1c 000000000050f468 00007fff4edc50c3 USER32!NtUserMessageCall+0xa 1d 000000000050f470 00007fff4edc5201 USER32!SendMessageWorker+0xfb 1e 000000000050f500 00007fff4ae59fa4 USER32!SendMessageW+0x105 1f 000000000050f560 00007fff4ae59f7f COMCTL32!Button_ReleaseCapture+0xd0 20 000000000050f5a0 00007fff4edc27a4 COMCTL32!Button_WndProc+0x8d3 21 000000000050f6c0 00007fff4edc2257 USER32!UserCallWinProcCheckWow+0x140 22 000000000050f780 00007fff4eddd831 USER32!DispatchMessageWorker+0x1a7 23 000000000050f800 00007fff4ae6919e USER32!IsDialogMessageW+0x127 24 000000000050f860 00007fff4ae69129 COMCTL32!Prop_IsDialogMessage+0x4a 25 000000000050f890 00007fff4ae68e71 COMCTL32!_RealPropertySheet+0x28b 26 000000000050f960 00007fff4aeda157 COMCTL32!_PropertySheet+0x49 27 000000000050f990 00007ff7da592c2c COMCTL32!PropertySheetA+0x53 28 000000000050fa30 00007ff7da592e26 NotMyfault!WinMain+0x248 29 000000000050fc40 00007fff4f361331 NotMyfault!__mainCRTStartup+0x18e 2a 000000000050fd00 00007fff4f508cd5 KERNEL32!BaseThreadInitThunk+0xd 2b 000000000050fd30 00000000`00000000 ntdll!RtlUserThreadStart+0x1d
Am I doing something wrong here? Am I wrong in reading the documentation that DV should be able to catch this simple violation?
Thanks in advance,
Sasha
[1] SpinLock Rule (WDM) - Windows drivers | Microsoft Learn
[2] DDI Compliance Checking - Windows drivers | Microsoft Learn