Skip to content

Commit 61feb64

Browse files
committed
[NTOS:KD64] kdx86.c: Fix Dr7 check to verify whether debugger disabling is allowed (reactos#7538)
Don't check the whole Dr7 value, but only the first 8 bits that correspond to the local/global enable breakpoints. We cannot check the whole value because some of the Dr7 bits are reserved always set to 1 (bit 10), or describe other debug state. References: - https://en.wikipedia.org/wiki/X86_debug_register#DR7_-_Debug_control - Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3 (3A, 3B, 3C, & 3D): System Programming Guide https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html Section "19.2.4 Debug Control Register (DR7)" (pgs. 644-646)
1 parent dfb4390 commit 61feb64

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ntoskrnl/kd64/i386/kdx86.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -426,23 +426,19 @@ NTSTATUS
426426
NTAPI
427427
KdpAllowDisable(VOID)
428428
{
429-
LONG i;
430-
ULONG Dr7;
429+
ULONG i;
431430

432431
/* Loop every processor */
433432
for (i = 0; i < KeNumberProcessors; i++)
434433
{
435-
/* Get its DR7 */
436-
Dr7 = KiProcessorBlock[i]->ProcessorState.SpecialRegisters.KernelDr7;
434+
PKPROCESSOR_STATE ProcessorState = &KiProcessorBlock[i]->ProcessorState;
437435

438-
/* Check if any processor breakpoints are active */
439-
if (Dr7 != 0)
440-
{
441-
/* We can't allow running without a debugger then */
436+
/* If any processor breakpoints are active,
437+
* we can't allow running without a debugger */
438+
if (ProcessorState->SpecialRegisters.KernelDr7 & 0xFF)
442439
return STATUS_ACCESS_DENIED;
443-
}
444440
}
445441

446-
/* No processor breakpoints; allow disabling the debugger */
442+
/* No processor breakpoints, allow disabling the debugger */
447443
return STATUS_SUCCESS;
448444
}

0 commit comments

Comments
 (0)