From patchwork Sun Nov 29 18:55:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esa Jaaskela X-Patchwork-Id: 106274 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.17604.1795978560867982948 for ; Sun, 29 Nov 2026 10:56:01 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@suomi24.fi header.s=MBO0001 header.b=ZhfofS27; spf=pass (domain: suomi24.fi, ip: 80.241.56.171, mailfrom: esa.jaaskela@suomi24.fi) Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4jcxF80BbzzMlmC; Sun, 29 Nov 2026 19:55:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suomi24.fi; s=MBO0001; t=1795978556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2BqGIq5QoEkAXagTrDzogAI/z7nOp3k07xoA1W78oDU=; b=ZhfofS27ChubCtClbw6QABNQ5tjWVBpodAvg5ogfpf5guEfPejwx4g+HT+eMua0H+kEGnL HDgxYl/8PZdMlZPpV9W0YSiQIgJQdoFsjBuQ1x8EkFMDsr+2C4ip/Lp8ogS+9XveaX4S4n j6zwgRne7C8fTzCBg3TkwrtFytAdBtfZ172/AD/0A3e88jpluQwNRc3wJbDUYwwuK+8vca 9PoTyIIF08fT5mmXdLN7+WtVcBGfMt9yjKYbhQuUawFOdrvVC+w4KXbG1Xsk1nQgczTPuy OneIgtLK8lgG+vWz0f0RNK9zJPZj8IcaylGZ2PCXoa9Bn+0Iq7eymX5VeRAOoA== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of esa.jaaskela@suomi24.fi designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=esa.jaaskela@suomi24.fi From: Esa Jaaskela To: yocto-patches@lists.yoctoproject.org Cc: Esa Jaaskela Subject: [meta-security][PATCH] meta-integrity: Add kernel certs to task hash Date: Sun, 29 Nov 2026 20:55:11 +0200 Message-ID: <20261129185511.843078-1-esa.jaaskela@suomi24.fi> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jcxF80BbzzMlmC List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Sun, 29 Nov 2026 18:56:09 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5586 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 --- meta-integrity/classes/kernel-modsign.bbclass | 4 ++++ meta-integrity/recipes-kernel/linux/linux_ima.inc | 4 ++++ 2 files changed, 8 insertions(+) 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)}"