diff mbox series

[meta-security] meta-integrity: Add kernel certs to task hash

Message ID 20261129185511.843078-1-esa.jaaskela@suomi24.fi
State New
Headers show
Series [meta-security] meta-integrity: Add kernel certs to task hash | expand

Commit Message

Esa Jaaskela Nov. 29, 2026, 6:55 p.m. UTC
The kernel is configured with the module signing key from MODSIGN_X509
and MODSIGN_PRIVKEY, and with the trusted certificates from
IMA_EVM_ROOT_CA, but the task hashes only contain the paths of these
files. When the files change but their paths stay the same, for example
after generating new keys into the same directory, the kernel is not
rebuilt. This can result in a key mismatch between the kernel and its
modules.

Add MODSIGN_X509 and IMA_EVM_ROOT_CA to the file checksums of
do_configure. A new key pair always comes with a new certificate, so
leave the private key out of the task hash.

Signed-off-by: Esa Jaaskela <esa.jaaskela@suomi24.fi>
---
 meta-integrity/classes/kernel-modsign.bbclass     | 4 ++++
 meta-integrity/recipes-kernel/linux/linux_ima.inc | 4 ++++
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/meta-integrity/classes/kernel-modsign.bbclass b/meta-integrity/classes/kernel-modsign.bbclass
index d3aa7fb..6219fb2 100644
--- a/meta-integrity/classes/kernel-modsign.bbclass
+++ b/meta-integrity/classes/kernel-modsign.bbclass
@@ -12,6 +12,10 @@  MODSIGN_PRIVKEY ?= "${MODSIGN_KEY_DIR}/privkey_modsign.pem"
 # The default is okay when using the example key directory.
 MODSIGN_X509 ?= "${MODSIGN_KEY_DIR}/x509_modsign.crt"
 
+# The kernel is built with the certificate and the modules are signed with the
+# key. Rebuild them when the certificate changes, not only when its path does.
+do_configure[file-checksums] += "${MODSIGN_X509}:True"
+
 # If this class is enabled, disable stripping signatures from modules
 # as well disable the debug symbols split
 INHIBIT_PACKAGE_STRIP = "1"
diff --git a/meta-integrity/recipes-kernel/linux/linux_ima.inc b/meta-integrity/recipes-kernel/linux/linux_ima.inc
index 415476a..83c63df 100644
--- a/meta-integrity/recipes-kernel/linux/linux_ima.inc
+++ b/meta-integrity/recipes-kernel/linux/linux_ima.inc
@@ -5,6 +5,10 @@  do_configure:append() {
     fi
 }
 
+# The kernel is built with the certificates in IMA_EVM_ROOT_CA. Rebuild it when
+# the file changes, not only when its path does.
+do_configure[file-checksums] += "${@'${IMA_EVM_ROOT_CA}:True' if bb.utils.contains('DISTRO_FEATURES', 'ima', True, False, d) and d.getVar('IMA_EVM_ROOT_CA') else ''}"
+
 KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'modsign', ' features/ima/modsign.scc', '', d)}"
 KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ima', ' features/ima/ima.scc', '', d)}"