ufrisk / pcileech

Direct Memory Access (DMA) Attack Software
GNU Affero General Public License v3.0
4.87k stars 718 forks source link

[Issue] pcileech library : Freeze every ~5s #55

Closed false closed 6 years ago

false commented 6 years ago

Hello,

After a while at tracking this issue I found out it was coming from pcileech. To explain my problem I will just describe the steps to reproduce :

You can test it with a read delay of 500 or 1, it won't change anything. Also put a Sleep(200) or so in your loop, it won't change anything. Every 5 seconds your application will freeze.

Any idea what the problem could be ? Is that an hardware problem or the lib that runs some routine every 5seconds ?

Thanks for your help, if you have any idea of what I could do please don't hesitate :-)

ufrisk commented 6 years ago

Yes, there is a housekeeping thread in there that once every 5 seconds will clear the page table cache (TLB) and do a partial refresh of the process list. Once every 15 seconds a complete refresh will be performed.

https://github.com/ufrisk/pcileech/blob/master/pcileech/vmmproc.c#L1209

You may alter the timings around with this PCILeech_VmmConfigGet / PCILeech_VmmConfigSet in the DLL.

Please note however that the TLB refresh is quite important if your target process allocates new virtual memory. But you can try it around changing the values - but setting them too high may lead to problems.

===

As a general note the library is completely single-threaded at the moment. The internal housekeeping thread and all calls to the PCILeech_Vmm* functions compete for the same lock at the moment.

There is quite some potential for improving upon this; and this is something I plan to look into. But I have more pressing matters to look into so I'm not even sure it will be this year.

===

If you just need to check for a value without interruption I guess you can up time timings on this housekeeping thread and whenever you wish to do something else restore it to let it refresh before you do your other tasks...

false commented 6 years ago

Hi @ufrisk , thanks for the fast answer. I may be wrong but I think I can't alter them directly through PCILeech_VmmConfigSet as I don't have access to the constants ; I will have a look to make it possible.

Anyway in a first step I have tested by changing hard coded values to much higher ones, and hourah it was indeed the root of my freezes! :-)

Thanks.