简体   繁体   English

如何使用 Yocto 为 Raspberry Pi 构建有效的 TPM2 映像?

[英]How to build a working TPM2 image for Raspberry Pi with Yocto?

I want to build a Linux System with Yocto for the Raspberry Pi with enabled IMA & TPM2.0 support.我想为 Raspberry Pi 构建一个带有 Yocto 的 Linux 系统,并启用 IMA 和 TPM2.0 支持。 Therefore I want to compile the kernel with IMA/EVM and TPM Configs and Recipes.因此,我想使用 IMA/EVM 和 TPM 配置和配方编译内核。

The IMA support should be enabled through the layer meta-secure-core/meta-integrity and adding DISTRO_FEATURE "ima", aswell as IMAGE_INSTALL_append "packagegroup-ima" for the tools.应通过元安全核心/元完整性层并为工具添加 DISTRO_FEATURE "ima" 以及 IMAGE_INSTALL_append "packagegroup-ima" 来启用 IMA 支持。 The TPM2 support should be enabled through the meta-security/meta-tpm layer and by adding MACHINE_FEATURES "tpm2" and installing "packagegroup-security-tpm2" via IMAGE_INSTALL_append.应通过 meta-security/meta-tpm 层并通过添加 MACHINE_FEATURES“tpm2”并通过 IMAGE_INSTALL_append 安装“packagegroup-security-tpm2”来启用 TPM2 支持。

Furthermore, if I understand it correctly, I need systemd as the init_manager.此外,如果我理解正确,我需要 systemd 作为 init_manager。

Yocto Version (Thud/2.6.3). Yocto 版本 (Thud/2.6.3)。 I tried Warrior but ran into build errors.我尝试了 Warrior,但遇到了构建错误。 This creates a 4.14.X Linux Kernel.这将创建一个 4.14.X Linux 内核。

bblayers.conf: bblayers.conf:

BBLAYERS ?= " \
  /<working-dir>/poky/meta \
  /<working-dir>/poky/meta-poky \
  /<working-dir>/poky/meta-yocto-bsp \
  /<working-dir>/meta-openembedded/meta-oe \
  /<working-dir>/meta-openembedded/meta-python \
  /<working-dir>/meta-openembedded/meta-networking \
  /<working-dir>/meta-openembedded/meta-perl \
  /<working-dir>/meta-security \
  /<working-dir>/meta-security/meta-tpm \
  /<working-dir>/meta-secure-core/meta-integrity \
  /<working-dir>/meta-raspberrypi \
  "

local.conf:本地.conf:

MACHINE = "raspberrypi3"
...
DISTRO_FEATURES_append += "systemd ima"
VIRTUAL-RUNTIME_init_manager = "systemd"
MACHINE_FEATURES += "tpm2"
IMAGE_INSTALL_append += "packagegroup-security-tpm2 packagegroup-ima"
ENABLE_SPI_BUS = "1"
RPI_EXTRA_CONFIG = "\n \
dtoverlay=tpm-slb9670 \n"

Builds:构建:

/<working-dir>/build/$ bitbake core-image-minimal

I expected the following entries in /proc/config.gz我希望 /proc/config.gz 中有以下条目

For TPM:对于 TPM:

    CONFIG_HW_RANDOM_TPM=y
    CONFIG_TCG_TPM=y
    CONFIG_TCG_TIS_CORE=y
    CONFIG_TCG_TIS=y
    CONFIG_TCG_CRB=y
    CONFIG_SECURITYFS=y

For IMA:对于 IMA:

    CONFIG_IMA=y
    # CONFIG_IMA_KEXEC is not set
    # CONFIG_IMA_LSM_RULES is not set
    CONFIG_IMA_WRITE_POLICY=y
    CONFIG_IMA_READ_POLICY=y
    CONFIG_IMA_MEASURE_PCR_IDX=10
    # CONFIG_IMA_TEMPLATE is not set
    # CONFIG_IMA_NG_TEMPLATE=y is not set
    CONFIG_IMA_SIG_TEMPLATE=y
    CONFIG_IMA_DEFAULT_TEMPLATE="ima-sig"
    # CONFIG_IMA_DEFAULT_HASH_SHA1 is not set
    CONFIG_IMA_DEFAULT_HASH_SHA256=y
    # CONFIG_IMA_DEFAULT_HASH_SHA512 is not set
    # CONFIG_IMA_DEFAULT_HASH_WP512 is not set
    CONFIG_IMA_DEFAULT_HASH="sha256"
    CONFIG_IMA_APPRAISE=y
    CONFIG_IMA_LOAD_X509=y
    CONFIG_IMA_APPRAISE_BOOTPARAM=y
    CONFIG_IMA_TRUSTED_KEYRING=y
    CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY=y
    CONFIG_IMA_BLACKLIST_KEYRING=y
    CONFIG_IMA_X509_PATH="/etc/keys/x509_ima.der"
    # CONFIG_IMA_APPRAISE_SIGNED_INIT is not set

However, searching on the built Linux on the Raspberry Pi for those settings none were enabled.但是,在 Raspberry Pi 上构建的 Linux 上搜索这些设置均未启用。

# modprobe configs
# cat /proc/config.gz | gunzip > running.conf
# cat running.conf | grep IMA

When I previously built for qemu, I didnt have those issues and I was able to confirm that my settings were enabled in the kernel.当我之前为 qemu 构建时,我没有遇到这些问题,我能够确认我的设置已在内核中启用。 Only the tools like evmctl were installed.只安装了 evmctl 之类的工具。

Also, my settings for /boot/config.txt of the Raspi didnt seem to have an effect.另外,我对 Raspi 的 /boot/config.txt 的设置似乎没有效果。 In fact, there was no /boot/config.txt for me to open at all.事实上,根本没有我可以打开的 /boot/config.txt。

Ultimately, the TPM2 abrmd didnt start during boot (error msg) and I obviously couldnt access the TPM at /dev/tpm* via SPI.最终,TPM2 abrmd 在启动期间没有启动(错误消息),而且我显然无法通过 SPI 在 /dev/tpm* 访问 TPM。 What did I do wrong?我做错了什么? I'm new to Yocto and System Building/Linux Kernel in general.一般来说,我是 Yocto 和系统构建/Linux 内核的新手。

Incase it's related to the Kernel Version, I tried to build for 4.19 but got build errors.如果它与内核版本有关,我尝试为 4.19 构建但遇到构建错误。 I also messed around with the meta-rpi layer from jumpnowtek but it didnt fix my problem.我还弄乱了 jumpnowtek 的元 rpi 层,但它没有解决我的问题。 There is also a meta-intel-iot-security/meta-integrity layer but its not maintained.还有一个元英特尔物联网安全/元完整性层,但没有维护。

you missed to modify the DTS.你错过了修改 DTS。

I create a guide and a github project to insert TPM on Raspberry.我创建了一个指南和一个 github 项目来在 Raspberry 上插入 TPM。 Please see the following:请参阅以下内容:

https://github.com/simonetolotti/meta-raspberrypi-web/tree/tpm https://github.com/simonetolotti/meta-raspberrypi-web/tree/tpm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM