From f66a7e2e482f6dbcf171018a60e6807d5a66a6ba Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 6 Jan 2020 00:51:43 +0100 Subject: [PATCH] [NTOS:KE:X64] Zero out the context in KiDispatchException --- ntoskrnl/ke/amd64/except.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/ke/amd64/except.c b/ntoskrnl/ke/amd64/except.c index 23ff7e016a9..40b01064d84 100644 --- a/ntoskrnl/ke/amd64/except.c +++ b/ntoskrnl/ke/amd64/except.c @@ -245,10 +245,13 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord, /* Increase number of Exception Dispatches */ KeGetCurrentPrcb()->KeExceptionDispatchCount++; + /* Zero out the context to avoid leaking kernel stack memor to user mode */ + RtlZeroMemory(&Context, sizeof(Context)); + /* Set the context flags */ Context.ContextFlags = CONTEXT_ALL; - /* Get a Context */ + /* Get the Context from the trap and exception frame */ KeTrapFrameToContext(TrapFrame, ExceptionFrame, &Context); /* Look at our exception code */