mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
[NTOSKRNL]
Mark lowest pages of P0BootStackData and KiDoubleFaultStackData as read-only to prevent unnoticed stack-overflow. CORE-4380 #resolve svn path=/trunk/; revision=64130
This commit is contained in:
parent
a475a70e24
commit
9199599d20
1 changed files with 28 additions and 2 deletions
|
@ -16,8 +16,8 @@
|
|||
/* GLOBALS *******************************************************************/
|
||||
|
||||
/* Boot and double-fault/NMI/DPC stack */
|
||||
UCHAR DECLSPEC_ALIGN(16) P0BootStackData[KERNEL_STACK_SIZE] = {0};
|
||||
UCHAR DECLSPEC_ALIGN(16) KiDoubleFaultStackData[KERNEL_STACK_SIZE] = {0};
|
||||
UCHAR DECLSPEC_ALIGN(PAGE_SIZE) P0BootStackData[KERNEL_STACK_SIZE] = {0};
|
||||
UCHAR DECLSPEC_ALIGN(PAGE_SIZE) KiDoubleFaultStackData[KERNEL_STACK_SIZE] = {0};
|
||||
ULONG_PTR P0BootStack = (ULONG_PTR)&P0BootStackData[KERNEL_STACK_SIZE];
|
||||
ULONG_PTR KiDoubleFaultStack = (ULONG_PTR)&KiDoubleFaultStackData[KERNEL_STACK_SIZE];
|
||||
|
||||
|
@ -679,6 +679,28 @@ KiSystemStartupBootStack(VOID)
|
|||
KiIdleLoop();
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
KiMarkPageAsReadOnly(
|
||||
PVOID Address)
|
||||
{
|
||||
PHARDWARE_PTE PointerPte;
|
||||
|
||||
/* Make sure the address is page aligned */
|
||||
ASSERT(ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE) == Address);
|
||||
|
||||
/* Get the PTE address */
|
||||
PointerPte = ((PHARDWARE_PTE)PTE_BASE) + ((ULONG_PTR)Address / PAGE_SIZE);
|
||||
ASSERT(PointerPte->Valid);
|
||||
ASSERT(PointerPte->Write);
|
||||
|
||||
/* Set as read-only */
|
||||
PointerPte->Write = 0;
|
||||
|
||||
/* Flush the TLB entry */
|
||||
__invlpg(Address);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
INIT_FUNCTION
|
||||
|
@ -796,6 +818,10 @@ AppCpuInit:
|
|||
|
||||
/* Check for break-in */
|
||||
if (KdPollBreakIn()) DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
|
||||
|
||||
/* Make the lowest page of the boot and double fault stack read-only */
|
||||
KiMarkPageAsReadOnly(P0BootStackData);
|
||||
KiMarkPageAsReadOnly(KiDoubleFaultStackData);
|
||||
}
|
||||
|
||||
/* Raise to HIGH_LEVEL */
|
||||
|
|
Loading…
Reference in a new issue