From 6bc61687e6ed47423737fc62880b6afa165c0154 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Jun 2026 15:39:05 +0300 Subject: [PATCH] [NTOS:KE/x64] Fix KiInitializeUserApc Set EFlags instead of "fixing" it. Prevents crashes in the thread initialization APC, when the thread has set the direction flag or trap flag. --- ntoskrnl/ke/amd64/usercall.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/ke/amd64/usercall.c b/ntoskrnl/ke/amd64/usercall.c index bab35e9e40e..6c747e04302 100644 --- a/ntoskrnl/ke/amd64/usercall.c +++ b/ntoskrnl/ke/amd64/usercall.c @@ -108,9 +108,8 @@ KiInitializeUserApc( TrapFrame->SegGs = KGDT64_R3_DATA | RPL_MASK; TrapFrame->SegSs = KGDT64_R3_DATA | RPL_MASK; - /* Sanitize EFLAGS, enable interrupts */ - TrapFrame->EFlags &= EFLAGS_USER_SANITIZE; - TrapFrame->EFlags |= EFLAGS_INTERRUPT_MASK; + /* Initialize EFLAGS */ + TrapFrame->EFlags = EFLAGS_INTERRUPT_MASK; } /*