From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: linux-security-module@vger.kernel.org,
linux-integrity@vger.kernel.org, linux-modules@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
keyrings@vger.kernel.org, David Howells <dhowells@redhat.com>,
David Woodhouse <dwmw2@infradead.org>,
Jonathan Corbet <corbet@lwn.net>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Sami Tolvanen <samitolvanen@google.com>,
Daniel Gomez <da.gomez@samsung.com>,
Mimi Zohar <zohar@linux.ibm.com>,
Roberto Sassu <roberto.sassu@huawei.com>,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
Eric Snowberg <eric.snowberg@oracle.com>,
Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
Peter Jones <pjones@redhat.com>,
Robert Holmes <robeholmes@gmail.com>,
Jeremy Cline <jcline@redhat.com>, Coiby Xu <coxu@redhat.com>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH RFC 1/1] module: Make use of platform keyring for module signature verify
Date: Mon, 2 Jun 2025 15:25:35 +0200 [thread overview]
Message-ID: <20250602132535.897944-2-vkuznets@redhat.com> (raw)
In-Reply-To: <20250602132535.897944-1-vkuznets@redhat.com>
This patch complements commit 278311e417be ("kexec, KEYS: Make use of
platform keyring for signature verify") and commit 6fce1f40e951
("dm verity: add support for signature verification with platform keyring")
and allows for signing modules using keys from SecureBoot 'db'. This may
come handy when the user has control over it, e.g. in a virtualized or a
cloud environment.
Suggested-by: Robert Holmes <robeholmes@gmail.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
Documentation/admin-guide/module-signing.rst | 6 ++++++
kernel/module/Kconfig | 11 +++++++++++
kernel/module/signing.c | 9 ++++++++-
security/integrity/Kconfig | 2 +-
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/Documentation/admin-guide/module-signing.rst b/Documentation/admin-guide/module-signing.rst
index a8667a777490..44ed93e586b9 100644
--- a/Documentation/admin-guide/module-signing.rst
+++ b/Documentation/admin-guide/module-signing.rst
@@ -118,6 +118,12 @@ This has a number of options available:
additional certificates which will be included in the system keyring by
default.
+ (5) :menuselection:`Use .platform keyring for verifying kernel modules signatures`
+ (``CONFIG_MODULE_SIG_PLATFORM``)
+
+ This option additionally allows modules to be signed with a key present
+ in ``.platform`` keyring, e.g. a SecureBoot 'db' key.
+
Note that enabling module signing adds a dependency on the OpenSSL devel
packages to the kernel build processes for the tool that does the signing.
diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig
index 39278737bb68..f1b85c14548a 100644
--- a/kernel/module/Kconfig
+++ b/kernel/module/Kconfig
@@ -340,6 +340,17 @@ config MODULE_SIG_HASH
default "sha3-384" if MODULE_SIG_SHA3_384
default "sha3-512" if MODULE_SIG_SHA3_512
+config MODULE_SIG_PLATFORM
+ bool "Use .platform keyring for verifying kernel modules signatures"
+ depends on INTEGRITY_PLATFORM_KEYRING
+ depends on MODULE_SIG
+ help
+ When selected, keys from .platform keyring can be used for verifying
+ modules signatures. In particular, this allows to use UEFI SecureBoot
+ 'db' for verification.
+
+ If unsure, say N.
+
config MODULE_COMPRESS
bool "Module compression"
help
diff --git a/kernel/module/signing.c b/kernel/module/signing.c
index a2ff4242e623..3327e7243211 100644
--- a/kernel/module/signing.c
+++ b/kernel/module/signing.c
@@ -61,10 +61,17 @@ int mod_verify_sig(const void *mod, struct load_info *info)
modlen -= sig_len + sizeof(ms);
info->len = modlen;
- return verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
+ ret = verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
VERIFY_USE_SECONDARY_KEYRING,
VERIFYING_MODULE_SIGNATURE,
NULL, NULL);
+ if (ret == -ENOKEY && IS_ENABLED(CONFIG_MODULE_SIG_PLATFORM)) {
+ ret = verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
+ VERIFY_USE_PLATFORM_KEYRING,
+ VERIFYING_MODULE_SIGNATURE,
+ NULL, NULL);
+ }
+ return ret;
}
int module_sig_check(struct load_info *info, int flags)
diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig
index 3c45f4f3455f..b7fa83d37a01 100644
--- a/security/integrity/Kconfig
+++ b/security/integrity/Kconfig
@@ -60,7 +60,7 @@ config INTEGRITY_PLATFORM_KEYRING
Provide a separate, distinct keyring for platform trusted keys, which
the kernel automatically populates during initialization from values
provided by the platform for verifying the kexec'ed kerned image
- and, possibly, the initramfs signature.
+ and, possibly, the initramfs signature and kernel modules signatures.
config INTEGRITY_MACHINE_KEYRING
bool "Provide a keyring to which Machine Owner Keys may be added"
--
2.49.0
next prev parent reply other threads:[~2025-06-02 13:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-02 13:25 [PATCH RFC 0/1] module: Optionally use .platform keyring for signatures verification Vitaly Kuznetsov
2025-06-02 13:25 ` Vitaly Kuznetsov [this message]
2025-06-02 18:34 ` [PATCH RFC 1/1] module: Make use of platform keyring for module signature verify James Bottomley
2025-06-03 8:52 ` Vitaly Kuznetsov
2025-06-03 13:03 ` James Bottomley
2025-06-04 7:47 ` Vitaly Kuznetsov
2025-06-05 8:34 ` Coiby Xu
2025-06-05 12:05 ` James Bottomley
2025-06-08 11:14 ` Coiby Xu
2025-06-04 17:01 ` [PATCH RFC 0/1] module: Optionally use .platform keyring for signatures verification Eric Snowberg
2025-06-04 17:34 ` James Bottomley
2025-06-05 7:54 ` Vitaly Kuznetsov
2025-06-05 12:22 ` James Bottomley
2025-06-05 13:43 ` Vitaly Kuznetsov
2025-06-05 15:49 ` James Bottomley
2025-06-09 8:58 ` Vitaly Kuznetsov
2025-06-05 13:35 ` Eric Snowberg
2025-06-05 14:56 ` Vitaly Kuznetsov
2025-06-05 14:35 ` Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250602132535.897944-2-vkuznets@redhat.com \
--to=vkuznets@redhat.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=corbet@lwn.net \
--cc=coxu@redhat.com \
--cc=da.gomez@samsung.com \
--cc=dhowells@redhat.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=dwmw2@infradead.org \
--cc=eric.snowberg@oracle.com \
--cc=jcline@redhat.com \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=kraxel@redhat.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=paul@paul-moore.com \
--cc=petr.pavlu@suse.com \
--cc=pjones@redhat.com \
--cc=robeholmes@gmail.com \
--cc=roberto.sassu@huawei.com \
--cc=samitolvanen@google.com \
--cc=serge@hallyn.com \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox