-
Notifications
You must be signed in to change notification settings - Fork 5.2k
IMA does not detect TPM while using RPi 5 #6217
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
Comments
Hello! I'm using LetsTrust TPM and adapted the Infineon remote attestation for RPi 5. I assume it's the same @Mangelmesa followed.
Thank you in advance, and even if a solution is not provided, direction on what actions can be taken would be greatly appreciated! |
Hello @ReportedUser!
Our idea now is to try and delay the loading of the IMA module to try and give some time for the TPM to load properly, but we don't have much hope for it to work. Any help from anyone more versed in the Linux kernel is appreciated. |
Hi @Mangelmesa, @ReportedUser, There was a recent request to move the late_initcall(init_ima) to the late_initcall_sync(init_ima). Refer to https://lore.kernel.org/linux-integrity/[email protected]/. Does that solve the problem with IMA going into TPM-bypass mode for you? To be on the safe side, I suggested trying at late_initcall(init_ima) and on failure trying again on late_initcall_sync(init_ima). |
Hi @mimizohar, We recompiled the kernel replacing the original |
Hello @mimizohar and Mangelmesa! I've also tried replacing Done a different test trying to do a loop (desperation) so it tries again later on, had the same results. Thanks a lot to both of you for the help and information sharing! |
I know it's obvious, but could you make sure that the TPM is builtin to the kernel, not as a kernel module. |
I've attached the .config file from our RPi5. I suppose that @ReportedUser will have more or less the same configuration that has been based on this documentation. Apart from this configuration now, we've tried using the TPM via I2C but the result is still the same. |
Hello @Mangelmesa, @mimizohar ! I believe I've managed to make it work, I'm going to check what change was the one that made it work and I'll give you an update. Just thought it would be worth notifying you! |
Hi! Sorry for the wait, That's what I tried: First, followed Infineon remote attestation instructions doing the corresponding changes for the raspberry pi 5. Then, the changes made so IMA is launched before the TPM were: Inside .config: Inside security/integrity/ima/ima_main.c added a delay at the beginning of the init_ima function (I believe it could be made with less time) and changed late_initcall(init_ima) to late_initcall_sync(init_ima):
Also, as I'm using a LetsTrust TPM I had to add:
To the drivers/char/tpm/tpm_tis_spi_main.c @Mangelmesa tell me if it works for you! |
Hello @ReportedUser, Thanks to your instructions it is working as intended now! I've attached a screenshot where it can be seen that IMA is now able to access the TPM and extend the boot_aggregate. I will close this issue now, hope that this is a semi-permanent fix and that it doesn't break in the future. Thanks again for providing your solution :) |
Thank you for finding a temporary solution. Mimi |
Hello @ReportedUser, @Mangelmesa, As per https://lore.kernel.org/linux-integrity/[email protected]/, please make sure these Kconfig options are builtin: |
Describe the bug
IMA seems to not detect the TPM on boot on the RPi 5, and therefore the message
"No TPM chip found, activating TPM-bypass!"
is displayed. The same building configuration for the kernel and a RPi 4 does not produce the error, and IMA is capable of extending the PCRs of the TPM. Looks like some merged fixes like #5003 do not solve this issue.Steps to reproduce the behaviour
Modify the Kernel by adding support for the IMA module (using ima-sig as default template and SHA256 as the hash algorithm), set the TPM module as built in:

Device Drivers --->Character devices ---> -*- TPM Hardware Support ---> <*> TPM Interface Specification 1.3 Interface / TPM 2.0 FIFO Interface - (SPI)
, as well as the SPI:Device Drivers --->[*] SPI support ---><*> BCM2835 SPI controller
. Build and copy the kernel to the SD card. Adddtparam=spi=on
anddtoverlay=tpm-slb9670
to /boot/firmware/config.txt, addima_policy=tcb
to /boot/firmware/cmdline.txt. Finally, add an IMA policy. After a reboot, the expected behavior is to see some value inboot_aggregate
given that the TPM is connected. However, all zeroes is obtained in this case, as if it does not exist:Device (s)
Raspberry Pi 5
System
Raspberry Pi reference 2024-03-15
OS and version: Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, f19ee211ddafcae300827f953d143de92a5c6624, stage5
Firmware version: 30cc5f37 (release) (embedded)
Kernel version: 6.6.31-v8-16k+ #2 SMP PREEMPT Fri Jun 7 10:41:54 CEST 2024 aarch64 GNU/Linux
Logs
Obtained running
dmesg | grep IMA
anddmesg | grep TPM
:[ 0.397724] ima: No TPM chip found, activating TPM-bypass!
[ 1.970687] systemd[1]: systemd 252.22-1-deb12u1 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
[ 4.445048] tpm_tis_spi spi0.1: 2.0 TPM (device-id 0x1D, rev-id 54)
[ 1.868523] systemd[1]: Successfully loaded the IMA custom policy /etc/ima/ima-policy.
[ 1.970687] systemd[1]: systemd 252.22-1~deb12u1 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
[ 2.416665] device-mapper: core: CONFIG_IMA_DISABLE_HTABLE is disabled. Duplicate IMA measurements will not be recorded in the IMA log.
Additional context
No response
The text was updated successfully, but these errors were encountered: