-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use user mode trace when installed Spectre&Meltdown patch. #6
Comments
nt!_KPROCESS I find UserDirectoryTableBase filed have user mode CR3 value. |
Just wondering, is there an 'official' way to get UserDirectoryTableBase ? (Sure you can hardcode KPROCESS but with patches that's just waiting for crashes) |
Hi, I'm facing the same problem. I've debugged The Error code returned by the Any idea here? Thanks! |
Thanks for bringing this issue to my attention. The current code has not been tested by Andrea or myself on systems that have had the meltdown patches applied. Meltdown did cause some architectural changes with the way page tables are accessed from usermode, however in the IOCTL handler, I'm not positive changing the directory base lookup is the correct fix since the kernel page tables should be able to access both kernel and process pages. I just moved from Austin to Seattle this weekend and all of my gear is in boxes for the next couple weeks until I can find time to unpack. If anyone would like to test a quick fix and report back here, you can change line 102 of IntelPt.cpp in the driver to access the offset of the new UserDirectoryTableBase at offset 0x278. The index of [5] should be updated to [79] on that line to reference the new offset to test this possible solution. If this does not fix it, I will need to get a kernel debugging setup again in a few weeks. WindowsIntelPT/WindowsPtDriver/IntelPt.cpp Line 102 in 66667b0
Andrea has since moved on to the Windows Kernel development team at MSFT and has restrictions on his opensource contributions. -rich |
Hi Rich, Let me know if there is something else I can try. Thanks!! |
You may want to strip the first 12 bits of targetcr3 Also, I noticed that targets running as administrator do not have the UserDirectoryTableBase filled in (it's not 0, it's 1) so they have the same CR3 in usermode as they do in kernelmode (In that case, use the old index 5) (Or leave the cr3 as it is and just remove the check. It's possible that intel-pt checks the exact CR3 value, so those bits may need to be set, but I am unsure) |
@illera88 You can try this: |
We are getting closer:
As you can see there is a problem either capturing the packets or parsing them with It complains about Any idea? |
Not sure as I don't have a parser, but this log looks like it's the log when it's not doing any instruction tracing and only system tracing events are in there. (clock changes etc...) So likely it's not seeing the CR3 it's looking for. |
it goes further so that's 'good'. could be it's that assert in the dpc handler that still checks index 5 (it'll fail) |
If you meant changing:
I already tried and crashed. |
Gonna analyze the crash dump with windbg. I'll let you know what I find |
Here are my results. I've commented out the lines 1187 and 1188 from When used:
If used:
or
or
or
I get a crash
|
Disassembled hal!HalpPerfInterrupt:
So, it looks like windows will BSOD if the first bit of any ADDR*_CFG is set to 1 this means that if you use the filterEn option to specify a start block only windows will BSOD So WindowsIntelPT/WindowsPtDriver/IntelPt.cpp Line 207 in 66667b0
For me this isn't such a problem, but it is a shame for people who wish to trace certain routines only (More efficient) |
@cheat-engine You should set hal!kddebuggernotpresent to NULL I think. |
Hi guys! Any update on this? Cheers |
I haven't checked it yet (First some other stuff to finish before I fix this in my own project) But from what i've surmised so far: Don't use range specifications (set notUsed for all 4 ranges, even if your CPU only supports 2) And if that doesn't work (or you really NEED them) attach a kernelmode debugger to windows. (Is there a way to do that without needing a 2nd PC with USB/Serial ? ) Alternatively, if there are no other PMI interrupts, use a really big buffer and use a polling mechanism to read out the data before the buffer gets full (There are other solutions like running windows inside a VM and fake the readout of the IA32_RTIT_CTL MSR value, or fake the cpuid result at boottime saying it's not supported, but that might be overkill) |
Some update on this, apparently attaching a kernelmode debugger won't stop the crash either when using regions edit:Yup, you need to null the pointer at hal!KdDebuggerNotPresent (which points to nt!KdDebuggerNotPresent ) and it won't BSOD Anyhow, my CE project can also generate these logs (Ultimap2) just tell it to not delete the trace files after processing (and either don't use regions, or do use regions but disable PMI's) and since overkill is my goto approach, i've written a virtual machine that will fake the readout of IA32_RTIT_CTL hiding the fact that ranges are used |
I can confirm the above analysis by cheat-engine is correct, the issue is actually due to a mitigation for the CyberARK patchguard bypass using intelpt which came out similar time as meltdown so that's why it was a bit confusing it wasn't just the page table issue. A solution to maintain full functionality is to either boot with debugging enabled and attach debugger or to patch nt to disable patchguard and then update the KdDebuggerNotPresent value. Other options are to use the linear logging mode or to use the ToPA without setting an IP filter which will require filtering to be done while processing the log files, which will have a drastic performance impact for online analysis, but should still be faster than BTS or usable for offline analysis. |
i havn't checked the latest windows build, but the prior one would bsod you with a kernelmode debugger attached as well because it didn't dereference the pointer to the value. And since the pointer is not null it will assume true |
Hi guys,
My Windows10 installed the newest patch this week ,it's used for patch Intel CPU--Spectre&Meltdown vulnerabilities. But today when I test WindowsIntelPt project on this machine, I find it is something wrong in user mode trace. And everything is Okay before I installed the newest windows patch...
Log like this:
`Talos Intel PT Test Application
Version 0.5
Intel Processor Tracing support for this CPU: YES
Would you like to do the Kernel Tests? [Y/N] n
Insert here the target process to trace: 872
872
On how many processors would you like to run the process? [1/4] 1
Creating trace files (binary and readable)... Success!
Creating target process... OK
Using IP filtering mode!
New Process main module base address: 0x7FF7F1640000, size 0x00041000.
Starting the Tracing and resuming the process...
Error!
*** PT Trace results ***
Number of traced CPUs: 1 - Affinity mask: 0x00000001.
CPU 0
Error!
Global number of PT packets acquired: 0.
All the dumps have been saved in "D:\mirror\transfer\Compiled_IntelPt\1746-01082018_Dumps".
Press any key to exit...`
I guess the problem is the newest windows used different CR3 between user mode and kernel mode.
The text was updated successfully, but these errors were encountered: