-
Notifications
You must be signed in to change notification settings - Fork 75
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
TPM deactivated on recent kernels > 4.2 tested #24
Comments
@xrayn Hi - sorry I don't get the question/problem Peter |
@PeterHuewe Hi Peter, sure I can elaborate. I simply want to use the TPM emulator on a Debian 9.0 system and forward the TPM to a qemu instance. After overcoming the compilation issues, by applying the mentioned patch, for some reason the TPM is decativated during start of qemu.
Basically there are now two possibilities, either the patch does not work on a functional level, meaning it messes up the messages sent and received via the kernel module (tpm_dev), or something else is broken. At this moment, I think the problem is not related to the kernel module, but related to linking the tpmd code to a recent OpenSSL version(Debian 9 uses OpenSSL 1.1 with changed API.). This suspicion doe not come out of the blue. For instance, I experienced also problems with Stefan Bergers code which is indeed related to OpenSSL (stefanberger/libtpms#7 (comment)). However, I did not have the time to test it properly for your tpm-emu code. I know this has all very little to do with your TPM-emulator, yet my educated guess is that due to OpenSSL's API changes, all code utilizing OpenSSL functions either directly or indirectly through trousers, is shows strange behavior as soon as OpenSSL 1.1 is used. If I have some time this week, I will try to link kernel 4.9 patched TPM-emu code against OpenSLL 1.0. In case the TPM forwarding to qemu then works, the chances are pretty high that the patch did indeed work properly and the problems are related to OpenSSL incompatibility. In case I do not succeed with this, the chances are high the 4.9 patch does not work as expected. Anyway, as soon as I have some results I will let you know here. Andre |
Hi Do you think you can tryout the "old" code on an "old kernel"? |
Hi, so I tried to re-activate/re-enable with the corresponding commands multiple times. So basically tpmd decativated / clear ... But it did not make any change. Indeed, the TPM device is availabel inside the VM, however, only certain command can be executed. E.g. tpm_version works, but tpm_takeownership fails (says TPM is deactivated). Now I'm a little confused. What do you mean with "old code" on an "old kernel"? I suppose if you can give me the 'code' and 'kernel' version combination you mean, I can do a test. |
Interesting that there seems to be a difference between 4.2 and 3.19. Thanks, |
So, I did some testing. As it turns out, neither the kernel nor OpenSSL caused the issue. The problem which is causing that the tpm gets deactivated, is due to a qemu bios image update introduced in 2.6 release (https://github.com/qemu/qemu/tree/stable-2.6). As a workaround to support the stable-2.6 qemu bios, I simply removed the function that causes the temporary deactivation (https://github.com/PeterHuewe/tpm-emulator/blob/master/tpm/tpm_cmd_handler.c). I could not detect any weird behavior inside the VM after doing this. The tpm worked as expected with nor errors.
Pleas note, this change requires a build without -Werror in CmakeLists.txt
In conclusion this means that the patches introduced by #21 are indeed working as expected. Moreover, qemu-bios from stable-2.5 (https://github.com/qemu/qemu/blob/stable-2.5/pc-bios/bios.bin) can be used for qemu for stable-2.4 up to current master builds. qemu-bios from 2.6 ((https://github.com/qemu/qemu/blob/stable-2.6/pc-bios/bios.bin) was only supported after applying listed patches. I suppose supporting the 2.6 bios will need an update somewhere in the code. @PeterHuewe I hope this helps. If you need more information, please let me know. Andre |
Thanks for digging into this. |
Not sure, I have also a system that forwards a hardware TPM to qemu. This works fine with the both qemu versions, i.e. stable-2.5 and stable-2.6. Unfortunately I could not find any indication what actually changed between both versions. Still, ignoring the error results in a working emulator, so maybe accepting the different initialization steps is also a viable option. |
@xrayn Is there any update on this? Is this fixed with newer qemu versions? |
@PeterHuewe Actually I did not follow up on this matter. :) If I find some time, I will have a look though. |
Hi, I tested the TPM emulator on three different machines with kernel version.
Machine 1:
4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u1 (2017-06-18) x86_64 GNU/Linux
Here the proposed patch from #21 was used to successfully compile the code.
Here, the TPM gets deactivated during the startup of a virtual machine. Using:
Version: QEMU emulator version 2.8.1(Debian 1:2.8+dfsg-6)
Here the debug log.
Machine 2:
The current code, was also tested on kernel 4.2.0-16-generic (build directly from master version https://github.com/PeterHuewe/tpm-emulator):
Version: QEMU emulator version 2.3.0 (Debian 1:2.3+dfsg-5ubuntu9.2)
Machine 3:
Same code base (current master) runs perfectly fine on QEMU emulator version 2.4.94 with kernel 3.13.0-76-generic #120-Ubuntu SMP
If more info is needed, let me know.
The text was updated successfully, but these errors were encountered: