All of lore.kernel.org
 help / color / mirror / Atom feed
* Yocto Kirkstone IMA Kernel Flags #kernel #kirkstone
@ 2025-04-02 12:32 miriam.rico
  2025-04-03 12:12 ` [yocto] " Gyorgy Sarvari
  2025-04-03 15:56 ` Bruce Ashfield
  0 siblings, 2 replies; 5+ messages in thread
From: miriam.rico @ 2025-04-02 12:32 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 4735 bytes --]

Hi,

I want to add IMA (Integrity Measurement Architecture) support to my Yocto build and I enabled it on my local.conf by adding:

DISTRO_FEATURES:append = " integrity ima"
IMAGE_CLASSES += "ima-evm-rootfs"
IMA_EVM_KEY_DIR = "${INTEGRITY_BASE}/data/debug-keys"
IMA_EVM_PRIVKEY = "${IMA_EVM_KEY_DIR}/ima_privkey.pem"
IMA_EVM_X509 = "${IMA_EVM_KEY_DIR}/x509_ima.der"
EVM_X509 = "${IMA_EVM_KEY_DIR}/x509_evm.der"

Also, I added the meta-integrity layer to my bblayers.conf file.

After building the image, I noticed that the used algorithm is sha1. I would like to enable the sha256 algorithm, but I am having problems with it. I have tried to enable it using the kernel flags, but I can't get it. I have reviewed the configuration that applies when IMA is enabled and found it to be as follows (looking at the config file generated after compiling the kernel and doing a grep for IMA, I am using *Kernel version 5.15* ):

# SPDX-License-Identifier: MIT
CONFIG_IMA=y
CONFIG_IMA_MEASURE_PCR_IDX=10
CONFIG_IMA_NG_TEMPLATE=y
CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"
CONFIG_IMA_DEFAULT_HASH_SHA1=y
CONFIG_IMA_DEFAULT_HASH="sha1"
CONFIG_IMA_APPRAISE=y
CONFIG_IMA_APPRAISE_BOOTPARAM=y
CONFIG_IMA_TRUSTED_KEYRING=y
CONFIG_SIGNATURE=y
CONFIG_IMA_WRITE_POLICY=y
CONFIG_IMA_READ_POLICY=y
CONFIG_IMA_LOAD_X509=y
CONFIG_IMA_X509_PATH="/etc/keys/x509_ima.der"

So I created a fragment file with the following:

CONFIG_IMA_SIG_TEMPLATE=y
CONFIG_IMA_DEFAULT_TEMPLATE="ima-sig"
CONFIG_IMA_DEFAULT_HASH_SHA256=y
CONFIG_IMA_DEFAULT_HASH="sha256"

Then, I add it to my linux-yocto_%.bbappend file:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += "file://enable-ima.cfg "

But after recompiling the kernel, the template and the hash remain "ima-ng" and "sha1".

I have also tried to create the fragment file using menuconfig, activating "ima-sig" and "sha256", using diffconfig to create fragment.cfg file, copying the fragment file to meta-my-layer/recipes-kernel/linux/files and adding it to my linux-yocto_%.bbappend file, but the result has been the same, the template and the algorithm have not changed.

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += "file://fragment.cfg "

I have been going through the tasks logs trying to see where the problem might be and found do_kernel_configme log. In the log, I saw the following:

Final scc/cfg list:  /home/.../Yocto/build/tmp/work/genericx86_64-poky-linux/linux-yocto/5.15.72+gitAUTOINC+441f5fe000_0b628306d1-r0/kernel-meta/bsp/common-pc-64/common-pc-64-standard.scc /home/
/home/.../Yocto/my_yocto_project/meta-my-layer/recipes-kernel/linux/files/enable-ima.cfg
/home/.../Yocto/my_yocto_project/meta-security/meta-tpm/recipes-kernel/linux/linux-yocto/tpm2.scc features/ima/ima.scc

So I thought that maybe the kernel features are applied after the user-created fragments. So, I added the following options to my enable-ima.cfg fragment to see if it was true or not.

CONFIG_IMA_APPRAISE_REQUIRE_KEXEC_SIGS=y
CONFIG_IMA_APPRAISE_REQUIRE_MODULE_SIGS=y
CONFIG_IMA_APPRAISE_BUILD_POLICY=y
CONFIG_IMA_APPRAISE_REQUIRE_FIRMWARE_SIGS=y
CONFIG_IMA_APPRAISE_REQUIRE_POLICY_SIGS=y

After recompiling the kernel, the result was the following:

# CONFIG_MDIO_BCM_UNIMAC is not set
CONFIG_FB_CFB_IMAGEBLIT=y
CONFIG_FB_SYS_IMAGEBLIT=y
CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
# CONFIG_HID_PRIMAX is not set
CONFIG_IMA=y
CONFIG_IMA_MEASURE_PCR_IDX=10
CONFIG_IMA_NG_TEMPLATE=y
# CONFIG_IMA_SIG_TEMPLATE is not set
CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"
CONFIG_IMA_DEFAULT_HASH_SHA1=y
# CONFIG_IMA_DEFAULT_HASH_SHA256 is not set
# CONFIG_IMA_DEFAULT_HASH_SHA512 is not set
CONFIG_IMA_DEFAULT_HASH="sha1"
CONFIG_IMA_WRITE_POLICY=y
CONFIG_IMA_READ_POLICY=y
CONFIG_IMA_APPRAISE=y
# CONFIG_IMA_ARCH_POLICY is not set
CONFIG_IMA_APPRAISE_BUILD_POLICY=y
CONFIG_IMA_APPRAISE_REQUIRE_FIRMWARE_SIGS=y
CONFIG_IMA_APPRAISE_REQUIRE_KEXEC_SIGS=y
CONFIG_IMA_APPRAISE_REQUIRE_MODULE_SIGS=y
CONFIG_IMA_APPRAISE_REQUIRE_POLICY_SIGS=y
CONFIG_IMA_APPRAISE_BOOTPARAM=y
CONFIG_IMA_APPRAISE_MODSIG=y
CONFIG_IMA_TRUSTED_KEYRING=y
# CONFIG_IMA_BLACKLIST_KEYRING is not set
CONFIG_IMA_LOAD_X509=y
CONFIG_IMA_X509_PATH="/etc/keys/x509_ima.der"
CONFIG_IMA_APPRAISE_SIGNED_INIT=y
CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=y
CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=y
# CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT is not set
# CONFIG_IMA_DISABLE_HTABLE is not set

The newly added options appear in the configuration.

Can anyone tell me which is the order of applying Kernel configuration? I am not sure whether I am following the correct order. How can I apply my Kernel configuration?

Any answer will be appreciated.

Thank you,

Miriam

[-- Attachment #2: Type: text/html, Size: 5610 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-30 15:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02 12:32 Yocto Kirkstone IMA Kernel Flags #kernel #kirkstone miriam.rico
2025-04-03 12:12 ` [yocto] " Gyorgy Sarvari
2025-04-03 15:56 ` Bruce Ashfield
2025-04-07  8:02   ` miriam.rico
2025-04-30 15:03     ` miriam.rico

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.