Author: tkreuzer
Date: Sat Apr 16 22:38:11 2016
New Revision: 71174
URL:
http://svn.reactos.org/svn/reactos?rev=71174&view=rev
Log:
[NTOSKRNL]
Modify the ret8 interrupt return path in KiTrapExitStub, so that nested interrupts (e.g.
as a result of an interrupt storm from a broken driver) will work more "like on
Windows", i.e., now the broken driver will not cause stack exhaustion anymore, but a
proper system hang! And it will be an even more efficient system hang than Windows has!
This is not the '90s. You can't just walk up and crash the system, you have to do
something cool first and do it properly "like Windows does", even if you're
not using the same assembly instructions.
Modified:
trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
Modified: trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S [iso-8859-1] Sat Apr 16
22:38:11 2016
@@ -264,6 +264,8 @@
#define KI_RESTORE_VOLATILES (KI_RESTORE_EAX OR KI_RESTORE_ECX_EDX)
MACRO(KiTrapExitStub, Name, Flags)
+ LOCAL ret8_instruction
+ LOCAL not_nested_int
PUBLIC @&Name&@4
@&Name&@4:
@@ -357,6 +359,18 @@
if (Flags AND KI_EXIT_RET8)
+ /* Check if we return from a nested interrupt, i.e. an interrupt
+ that occurred in the ret8 return path between restoring
+ EFLAGS and returning with the ret instruction. */
+ cmp dword ptr [esp], offset ret8_instruction
+ jne not_nested_int
+
+ /* This is a nested interrupt, so we have 2 IRET frames.
+ Skip the first, and go directly to the previous return address.
+ Do not pass Go. Do not collect $200 */
+ add esp, 12
+
+not_nested_int:
/* We are at the IRET frame, so push EFLAGS first */
push dword ptr [esp + 8]
@@ -387,6 +401,7 @@
elseif (Flags AND KI_EXIT_RET8)
/* Return to kernel mode with a ret 8 */
+ret8_instruction:
ret 8
elseif (Flags AND KI_EXIT_RET)