PS: setting KiUserCetAllowed must have happened earlier than nt!KiInitializeKernel. I stopped too late.
What is causing my computer to BSOD at random times?
I have a custom built gaming PC that has recently been blue screening randomly and it seems completely unprompted. It happens when I'm in the middle of a game, or when I'm working on a Word document with Spotify playing, or when I'm browsing google chrome with nothing else open. I don't know what could be causing it.
The error I get is always "KMODE_EXCEPTION_NOT_HANDLED"
I recently had an issue where my computer would BSOD with the same error every time I woke it up from sleep mode. I got a warranty replacement for my RAM and that fixed that issue. These BSODs seem to be caused by something else. This also means that I find it highly unlikely that there's something wrong with my RAM.
Here is a link to the dump files I've gathered so far. I will add more as my computer continues to crash. It happens once every few hours, it seems.
https://drive.google.com/drive/folders/1_QM2imGRMNnQtNsdU8W98a16JUMTyj0d?usp=sharing
Does anybody know what could be causing this issue? Do the dump files point to anything specifically that could be causing the crashes?
Thank you
Windows for home | Windows 10 | Performance and system failures
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
84 answers
Sort by: Newest
-
Anonymous
2025-01-08T14:15:14+00:00 -
Anonymous
2025-01-08T13:57:56+00:00 In other words, all people that previously got murdered by the nameless (and incompetent) shellcode can now use the hardcore override and leave Core Isolation's Memory Integrity's protection, and have the shellcode running without murder part. But don't complain when your (ndis) routines get overwritten afterwards by something and you get critical kernel corruption. (I still wonder about that ndis-overwrite part, btw. It happened only to Alex as far as I know, not to all the others with shellcode.)
-
Anonymous
2025-01-08T13:43:01+00:00 I finally found an own laptop with a new enough CPU, because I wouldn't want to do somewhat dangerous experiments on a friends computer.
I can positively ack empirically the following:
"xsaveremovefeature 0x800" hardcore removes the cr4 bit in full, KiUserCetAllowed will be zero. This happens before ntoskrnl "really" starts, at boot time. (I was boot-debugging.) It is truly a handy hardcore override. The cr4.CET bit will be gone, all shadow stack protection will be gone, no matter what the user has set in control panel. And I think it works just with admin rights, e.g., it does not require disabling secure boot or similar things. (Obviously I can't verify that, because kernel debugging requires secure boot off.)
As I did not know the revert command for the esoteric "xsaveremovefeature 0x800" (hey, I still wonder where Gary got that from), I used bcdedit export/import option, as you can see in my proof of concept:
kb # RetAddr : Args to Child : Call Site 00 fffff801`3cd2b6ca : fffff801`36b78c00 fffff801`383955e0 00000000`00000004 00000000`00000004 : nt!DbgBreakPointWithStatus 01 fffff801`3cc74057 : fffff801`36b78c00 fffff801`36b78c00 00000000`00000001 fffff801`3cf4c6c0 : nt!InitBootProcessor+0x536 02 fffff801`3cc71279 : fffff801`3fb70000 00000000`00000000 00000000`00000003 fffff801`38395ba0 : nt!KiInitializeKernel+0x417 03 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : nt!KiSystemStartup+0x269 !process -1 0 PROCESS fffff8013cf48f40 SessionId: none Cid: 0000 Peb: 00000000 ParentCid: 0000 DirBase: 001ae000 ObjectTable: 00000000 HandleCount: 0. Image: (we are at boot and the OS isn't initialized yet) db nt!KiUserCetAllowed L1 fffff801`3cf1c061 01 r cr4 cr4=0000000000b50ef8 db nt!KiUserCetAllowed L1 fffff801`3cf1c061 01 === bcdedit /export "c:\temp\bcdstorebackup" + bcdedit /set xsaveremovefeature 0x800 + reboot === db nt!KiUserCetAllowed L1 fffff805`0b11c061 00 r cr4 cr4=0000000000350ef8 Binary: 00000000 00000000 00000000 00000000 00000000 00110101 00001110 11111000 Bit 23 (Intel CET bit) is off. === bcdedit /import "c:\temp\bcdstorebackup" + reboot === Reboot runs into a little bit scary bcd error (??), followed by immediate auto-reboot, and then a normal boot (with success and restored configuration).* * This did not happen on a later second attempt. r cr4 cr4=0000000000b50ef8 Binary: 00000000 00000000 00000000 00000000 00000000 10110101 00001110 11111000 Bit 23 (Intel CET bit) is set again. -
Anonymous
2025-01-08T13:07:56+00:00 Hello vivs_lunchtime,
I think that everyone can use the xsaveremovefeature 0x800 option; when used, XSTATE_CET_U in SharedUserData.XState.EnabledSupervisorFeatures will not be set and the CET flag in CR4 will not be set. Any feature that depends on CET will not be enabled.
In Alex's original configuration, XSTATE_CET_U and CR4.CET were set. A "side-effect" of setting CR4.CET (i.e. not being able to clear CR0.WP) caused (presumably) PatchGuard to crash the system.
According to the Intel manual, CET provides two capabilities: Shadow Stack and Indirect Branch Tracking.
For brevity, in the following text I have omitted all of my usual "I think/believe" qualifications.
Starting from Windows build 19041, user-mode shadow stack "functionality" is enabled for all threads. I put "functionality" in quotes because what actually happens is dependent on a number of factors, including:
- Whether the DLL has the IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT mark (all Microsoft Windows DLLs should have this flag set).
- Whether SetProcessMitigationPolicy(ProcessUserShadowStackPolicy, ...) has been called (to change default behaviour).
If DLLs marked with IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT behave correctly, there should be no easily observable impact of the user-mode shadow stacks. There may be some visible indications of shadow stack activity in the Microsoft-Windows-Security-Mitigations event log.
KiUserCetAllowed does not "govern" kernel-mode shadow stacks - it just reflects the setting of CR4.CET. If KiUserCetAllowed is not set then CET is not available and kernel-mode shadow stacks can't be used; as you mentioned, there are also other prerequisites for kernel-mode shadow stacks.
I earlier wrote:
if KiUserCetAllowed then set bit CET in CR4
KiUserCetAllowed is set if SharedUserData.XState.EnabledSupervisorFeatures has bit 11 (0x800) (XSTATE_CET_U) set
KiInitializeXSave initializes SharedUserData.XState.EnabledSupervisorFeatures (combines CPUID information with BCD information)
The order of the text matches how I came to the information:
Search the code in ntoskrnl looking for writes to CR4; check if CET is possibly being set and, if so, what influences the decision (e.g. value of KiUserCetAllowed).
Search the code in ntoskrnl looking for modifications of KiUserCetAllowed and what determines the value set (e.g. value of SharedUserData.XState.EnabledSupervisorFeatures).
Just one further search was needed to see that the CPUID instruction and BCD determined the value of SharedUserData.XState.EnabledSupervisorFeatures.
I think that "bcdedit /deletevalue xsaveremovefeature" should "undo" the bcdedit test but, like you, I have not dared to try it.
Gary
-
Anonymous
2025-01-08T12:32:27+00:00 Addendum: KiUserCetAllowed governs the kernel mode CET then as well? And you mean, governs the bit or you mean setup of the shadow stack?
(How do you know / find out?)
I did not dare to use the xRemoveSaveFeature 0x800, because I didn't know for sure if I would be able to revert it. So I don't know how CR4 looks like after using this command and the reboot.
Is there a revert command for xRemoveSaveFeature 0x800?