Kernel modules are currently only signed when CONFIG_MODULE_SIG is enabled.
The kernel module signing key is a self-signed CA only loaded onto the
.builtin_trusted_key keyring. On secure boot enabled systems with an arch
specific IMA policy enabled, but without MODULE_SIG enabled, kernel modules
are not signed, nor is the kernel module signing public key loaded onto the
IMA keyring.
In order to load the the kernel module signing key onto the IMA trusted
keyring ('.ima'), the certificate needs to be signed by a CA key either on
the builtin or secondary keyrings. This series of patches enables IMA
verification of signed kernel modules by:
* Defining a kernel CA key. The CA key signs the kernel module signing key
and is loaded onto .builtin_trusted_key keyring, only when the kernel
module signing key is loaded onto the .ima keyring.
* Enable module signing at build time for IMA_APPRAISE_MODSIG as well
Nayna Jain (5):
keys: cleanup build time module signing keys
keys: generate self-signed module signing key using CSR
ima: update kernel module signing process during build
keys: define build time generated ephemeral kernel CA key
ima: enable loading of build time generated key to .ima keyring
Makefile | 9 ++--
certs/Kconfig | 2 +-
certs/Makefile | 77 ++++++++++++++++++++++++++++++++---
certs/system_certificates.S | 16 +++++++-
certs/system_keyring.c | 56 +++++++++++++++++++------
include/keys/system_keyring.h | 9 +++-
init/Kconfig | 6 +--
security/integrity/digsig.c | 4 ++
8 files changed, 151 insertions(+), 28 deletions(-)
--
2.18.1
The "mrproper" target is still looking for build time generated keys
in the old path instead of certs/ directory.
This patch fixes the path as well removes the names of the files which
are no longer generated.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
Fixes: 28a68f828266 ("modsign: Use single PEM file for autogenerated key")
---
Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Loading a key on the IMA trusted keyring requires the key be signed
by an existing key on the builtin or secondary trusted keyring.
Creating a Certificate Signing Request (CSR) allows the certificate
to be self-signed or signed by a CA.
This patch generates a self-signed module signing key using CSR.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
Makefile | 3 ++-
certs/Makefile | 15 +++++++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
@@ -60,11 +60,18 @@ $(obj)/signing_key.pem: $(obj)/x509.genkey@$(kecho)"### needs to be run as root, and uses a hardware random"@$(kecho)"### number generator if one is available."@$(kecho)"###"-$(Q)opensslreq-new-nodes-utf8-$(CONFIG_MODULE_SIG_HASH)-days36500\--batch-x509-config$(obj)/x509.genkey\--outformPEM-out$(obj)/signing_key.pem\--keyout$(obj)/signing_key.pem\+$(Q)opensslreq-new-nodes-utf8\+-batch-config$(obj)/x509.genkey\+-outformPEM-out$(obj)/signing_key.csr\+-keyout$(obj)/signing_key.key-extensionsmyexts\$($(quiet)redirect_openssl)+$(Q)opensslx509-req-days36500-in$(obj)/signing_key.csr\+-outformPEM-out$(obj)/signing_key.crt\+-signkey$(obj)/signing_key.key\+-$(CONFIG_MODULE_SIG_HASH)-extensionsmyexts\+-extfile$(obj)/x509.genkey\+$($(quiet)redirect_openssl)+@cat$(obj)/signing_key.key$(obj)/signing_key.crt>>$(obj)/signing_key.pem@$(kecho)"###"@$(kecho)"### Key pair generated."@$(kecho)"###"
The kernel build process currently only signs kernel modules when
MODULE_SIG is enabled. Also, sign the kernel modules at build time when
IMA_APPRAISE_MODSIG is enabled.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
certs/Kconfig | 2 +-
init/Kconfig | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
@@ -4,7 +4,7 @@ menu "Certificates for signature checking"configMODULE_SIG_KEYstring"File name or PKCS#11 URI of module signing key"default"certs/signing_key.pem"-depends onMODULE_SIG+depends onMODULE_SIG||IMA_APPRAISE_MODSIGhelpProvidethefilenameofaprivatekey/certificateinPEMformat,oraPKCS#11URIaccordingtoRFC7512.Thefileshouldcontain,or
@@ -2172,7 +2172,7 @@ comment "Do not forget to sign required modules with scripts/sign-file"choiceprompt"Which hash algorithm should modules be signed with?"-depends onMODULE_SIG+depends onMODULE_SIG||IMA_APPRAISE_MODSIGhelpThisdetermineswhichsortofhashingalgorithmwillbeusedduringsignaturegeneration.Thisalgorithm_must_bebuiltintothekernel
Certificates being loaded onto the IMA trusted keyring must be signed by
a key on either the builtin and secondary trusted keyring.
This patch creates and includes in the kernel image an ephemeral CA
key, at build time when IMA_APPRAISE_MODSIG is enabled.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
Makefile | 2 ++
certs/Makefile | 68 ++++++++++++++++++++++++++++++++++---
certs/system_certificates.S | 16 ++++++++-
3 files changed, 80 insertions(+), 6 deletions(-)
@@ -32,6 +32,14 @@ endif # CONFIG_SYSTEM_TRUSTED_KEYRINGclean-files:=x509_certificate_list.x509.listifeq ($(CONFIG_MODULE_SIG),y)+SIGN_KEY=y+endif++ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)+SIGN_KEY=y+endif++ifdef SIGN_KEY################################################################################# If module signing is requested, say by allyesconfig, but a key has not been
@@ -51,6 +59,16 @@ silent_redirect_openssl = 2>/dev/null# external private key, because 'make randconfig' might enable such a# boolean option and we unfortunately can't make it depend on !RANDCONFIG.ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem")++ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)+# openssl arguments for CA Signed certificate.+CA_KEY=certs/ca_signing_key.pem+SIGNER=-CA$(CA_KEY)-CAkey$(CA_KEY)-CAcreateserial+else+# openssl arguments for Self Signed certificate.+SIGNER=-signkey$(obj)/signing_key.key+endif # CONFIG_IMA_APPRAISE_MODSIG+$(obj)/signing_key.pem:$(obj)/x509.genkey@$(kecho)"###"@$(kecho)"### Now generating an X.509 key pair to be used for signing modules."
@@ -60,14 +78,23 @@ $(obj)/signing_key.pem: $(obj)/x509.genkey@$(kecho)"### needs to be run as root, and uses a hardware random"@$(kecho)"### number generator if one is available."@$(kecho)"###"+ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)+ # Generate kernel build time CA Certificate.+@$(Q)opensslreq-new-nodes-utf8\+-$(CONFIG_MODULE_SIG_HASH)-days36500\+-subj"/CN=Build time autogenerated kernel CA key"\+-batch-x509-config$(obj)/x509.genkey\+-outformPEM-out$(CA_KEY)\+-keyout$(CA_KEY)-extensionsca_ext\+$($(quiet)redirect_openssl)+endif # CONFIG_IMA_APPRAISE_MODSIG$(Q)opensslreq-new-nodes-utf8\-batch-config$(obj)/x509.genkey\-outformPEM-out$(obj)/signing_key.csr\-keyout$(obj)/signing_key.key-extensionsmyexts\$($(quiet)redirect_openssl)$(Q)opensslx509-req-days36500-in$(obj)/signing_key.csr\--outformPEM-out$(obj)/signing_key.crt\--signkey$(obj)/signing_key.key\+-outformPEM-out$(obj)/signing_key.crt$(SIGNER)\-$(CONFIG_MODULE_SIG_HASH)-extensionsmyexts\-extfile$(obj)/x509.genkey\$($(quiet)redirect_openssl)
@@ -95,19 +122,50 @@ $(obj)/x509.genkey:@echo>>$@"keyUsage=digitalSignature"@echo>>$@"subjectKeyIdentifier=hash"@echo>>$@"authorityKeyIdentifier=keyid"+@echo>>$@+@echo>>$@"[ ca_ext ]"+@echo>>$@"keyUsage=critical,keyCertSign"+@echo>>$@"basicConstraints=critical,CA:TRUE,pathlen:0"+@echo>>$@"subjectKeyIdentifier=hash"+@echo>>$@"authorityKeyIdentifier=keyid"endif # CONFIG_MODULE_SIG_KEY$(eval$(callconfig_filename,MODULE_SIG_KEY))+SUBJECT=CN=Buildtimeautogeneratedkernelkey+ISSUER=$(shellopensslx509-incerts/signing_key.crt-noout-issuer)# If CONFIG_MODULE_SIG_KEY isn't a PKCS#11 URI, depend on it++# GCC PR#66871 again.+ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)++# Remove existing keys if it is self-signed.+$(if$(findstring$(SUBJECT),$(ISSUER)),$(shellrm-fcerts/signing_key.* certs/x509.genkey))+CA_KEY=certs/ca_signing_key.pem++$(obj)/system_certificates.o:$(obj)/ca_signing_key.x509 $(obj)/signing_key.x509++targets+=ca_signing_key.x509+$(obj)/ca_signing_key.x509:$(obj)/signing_key.x509 scripts/extract-certFORCE+$(callif_changed,extract_certs,$(CA_KEY))++targets+=signing_key.x509+$(obj)/signing_key.x509:$(obj)/signing_key.pemscripts/extract-certFORCE+$(callif_changed,extract_certs,$(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY))+else++# Remove existing keys if it is CA signed.+$(if$(findstring$(SUBJECT),$(ISSUER)),,$(shellrm-fcerts/ca_signing_key.* certs/signing_key.* certs/x509.genkey))+ifeq ($(patsubst pkcs11:%,%,$(firstword $(MODULE_SIG_KEY_FILENAME))),$(firstword $(MODULE_SIG_KEY_FILENAME)))X509_DEP:=$(MODULE_SIG_KEY_SRCPREFIX)$(MODULE_SIG_KEY_FILENAME)endif-# GCC PR#66871 again.$(obj)/system_certificates.o:$(obj)/signing_key.x509targets+=signing_key.x509-$(obj)/signing_key.x509:scripts/extract-cert$(X509_DEP)FORCE+$(obj)/signing_key.x509:certs/signing_key.pemscripts/extract-cert$(X509_DEP)FORCE$(callif_changed,extract_certs,$(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY))-endif # CONFIG_MODULE_SIG++endif # CONFIG_IMA_APPRAISE_MODSIG+endif # SIGN_KEY
The kernel currently only loads the kernel module signing key onto
the builtin trusted keyring. To support IMA, load the module signing
key selectively either onto builtin or ima keyring based on MODULE_SIG
or MODULE_APPRAISE_MODSIG config respectively; and loads the CA kernel
key onto builtin trusted keyring.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
certs/system_keyring.c | 56 +++++++++++++++++++++++++++--------
include/keys/system_keyring.h | 9 +++++-
security/integrity/digsig.c | 4 +++
3 files changed, 55 insertions(+), 14 deletions(-)
@@ -131,19 +132,12 @@ static __init int system_trusted_keyring_init(void)*/device_initcall(system_trusted_keyring_init);-/*-*Loadthecompiled-inlistofX.509certificates.-*/-static__initintload_system_certificate_list(void)+static__initintload_cert(constu8*p,constu8*end,structkey*keyring,+unsignedlongflags){key_ref_tkey;-constu8*p,*end;size_tplen;-pr_notice("Loading compiled-in X.509 certificates\n");--p=system_certificate_list;-end=p+system_certificate_list_size;while(p<end){/* Each cert begins with an ASN.1 SEQUENCE tag and must be more*than256bytesinsize.
@@ -111,8 +111,12 @@ static int __init __integrity_init_keyring(const unsigned int id,}else{if(id==INTEGRITY_KEYRING_PLATFORM)set_platform_trusted_keys(keyring[id]);+if(id==INTEGRITY_KEYRING_IMA)+load_module_cert(keyring[id],KEY_ALLOC_NOT_IN_QUOTA);}+pr_info("Loading key to ima keyring\n");+returnerr;}
From: Stefan Berger <stefanb@linux.ibm.com> Date: 2021-02-11 21:58:27
On 2/11/21 2:54 PM, Nayna Jain wrote:
The "mrproper" target is still looking for build time generated keys
in the old path instead of certs/ directory.
This patch fixes the path as well removes the names of the files which
are no longer generated.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
Fixes: 28a68f828266 ("modsign: Use single PEM file for autogenerated key")
I was curious about some of the files and how they were created in the
past but couldn't see it in the hostory of the Makefile. The above
Fixes tag seems to give the wrong commit id:
commit 28a68f828266754c2bd64b87873e8099e3f8fe0c
Author: Dave Airlie [off-list ref]
Date: Thu Oct 29 13:59:45 2020 +1000
drm/radeon/ttm: use multihop
From: Stefan Berger <stefanb@linux.ibm.com> Date: 2021-02-11 22:02:07
On 2/11/21 2:54 PM, Nayna Jain wrote:
quoted hunk
Loading a key on the IMA trusted keyring requires the key be signed
by an existing key on the builtin or secondary trusted keyring.
Creating a Certificate Signing Request (CSR) allows the certificate
to be self-signed or signed by a CA.
This patch generates a self-signed module signing key using CSR.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
Makefile | 3 ++-
certs/Makefile | 15 +++++++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
@@ -60,11 +60,18 @@ $(obj)/signing_key.pem: $(obj)/x509.genkey@$(kecho)"### needs to be run as root, and uses a hardware random"@$(kecho)"### number generator if one is available."@$(kecho)"###"-$(Q)opensslreq-new-nodes-utf8-$(CONFIG_MODULE_SIG_HASH)-days36500\--batch-x509-config$(obj)/x509.genkey\--outformPEM-out$(obj)/signing_key.pem\--keyout$(obj)/signing_key.pem\+$(Q)opensslreq-new-nodes-utf8\+-batch-config$(obj)/x509.genkey\+-outformPEM-out$(obj)/signing_key.csr\+-keyout$(obj)/signing_key.key-extensionsmyexts\$($(quiet)redirect_openssl)+$(Q)opensslx509-req-days36500-in$(obj)/signing_key.csr\+-outformPEM-out$(obj)/signing_key.crt\+-signkey$(obj)/signing_key.key\+-$(CONFIG_MODULE_SIG_HASH)-extensionsmyexts\+-extfile$(obj)/x509.genkey\+$($(quiet)redirect_openssl)+@cat$(obj)/signing_key.key$(obj)/signing_key.crt>>$(obj)/signing_key.pem
Could you not just rename signing_key.key to signing_key.pem (as it was
before) and that would be it? Why do you need the .crt in that pem bundle?
Stefan
From: Stefan Berger <stefanb@linux.ibm.com> Date: 2021-02-11 22:15:09
On 2/11/21 2:54 PM, Nayna Jain wrote:
quoted hunk
Certificates being loaded onto the IMA trusted keyring must be signed by
a key on either the builtin and secondary trusted keyring.
This patch creates and includes in the kernel image an ephemeral CA
key, at build time when IMA_APPRAISE_MODSIG is enabled.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
Makefile | 2 ++
certs/Makefile | 68 ++++++++++++++++++++++++++++++++++---
certs/system_certificates.S | 16 ++++++++-
3 files changed, 80 insertions(+), 6 deletions(-)
@@ -32,6 +32,14 @@ endif # CONFIG_SYSTEM_TRUSTED_KEYRINGclean-files:=x509_certificate_list.x509.list ifeq ($(CONFIG_MODULE_SIG),y)+SIGN_KEY=y+endif++ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)+SIGN_KEY=y+endif++ifdef SIGN_KEY ############################################################################### # # If module signing is requested, say by allyesconfig, but a key has not been
@@ -51,6 +59,16 @@ silent_redirect_openssl = 2>/dev/null # external private key, because 'make randconfig' might enable such a # boolean option and we unfortunately can't make it depend on !RANDCONFIG. ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem")++ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)+# openssl arguments for CA Signed certificate.+CA_KEY=certs/ca_signing_key.pem+SIGNER=-CA$(CA_KEY)-CAkey$(CA_KEY)-CAcreateserial+else+# openssl arguments for Self Signed certificate.+SIGNER=-signkey$(obj)/signing_key.key+endif # CONFIG_IMA_APPRAISE_MODSIG+$(obj)/signing_key.pem:$(obj)/x509.genkey@$(kecho)"###"@$(kecho)"### Now generating an X.509 key pair to be used for signing modules."
@@ -60,14 +78,23 @@ $(obj)/signing_key.pem: $(obj)/x509.genkey@$(kecho)"### needs to be run as root, and uses a hardware random"@$(kecho)"### number generator if one is available."@$(kecho)"###"+ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)+ # Generate kernel build time CA Certificate.+@$(Q)opensslreq-new-nodes-utf8\+-$(CONFIG_MODULE_SIG_HASH)-days36500\+-subj"/CN=Build time autogenerated kernel CA key"\+-batch-x509-config$(obj)/x509.genkey\+-outformPEM-out$(CA_KEY)\+-keyout$(CA_KEY)-extensionsca_ext\+$($(quiet)redirect_openssl)+endif # CONFIG_IMA_APPRAISE_MODSIG$(Q)opensslreq-new-nodes-utf8\-batch-config$(obj)/x509.genkey\-outformPEM-out$(obj)/signing_key.csr\-keyout$(obj)/signing_key.key-extensionsmyexts\$($(quiet)redirect_openssl)$(Q)opensslx509-req-days36500-in$(obj)/signing_key.csr\--outformPEM-out$(obj)/signing_key.crt\--signkey$(obj)/signing_key.key\+-outformPEM-out$(obj)/signing_key.crt$(SIGNER)\-$(CONFIG_MODULE_SIG_HASH)-extensionsmyexts\-extfile$(obj)/x509.genkey\$($(quiet)redirect_openssl)
It may make things easier (also below) if the CA was always created and
the kernel signing key was always signed by that CA rather than doing
this only in the IMA_APPRAISE_MODSIG case. Maybe someone else has an
opinion on that?
From: Stefan Berger <stefanb@linux.ibm.com> Date: 2021-02-11 22:33:06
On 2/11/21 2:54 PM, Nayna Jain wrote:
quoted hunk
The kernel currently only loads the kernel module signing key onto
the builtin trusted keyring. To support IMA, load the module signing
key selectively either onto builtin or ima keyring based on MODULE_SIG
or MODULE_APPRAISE_MODSIG config respectively; and loads the CA kernel
key onto builtin trusted keyring.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
certs/system_keyring.c | 56 +++++++++++++++++++++++++++--------
include/keys/system_keyring.h | 9 +++++-
security/integrity/digsig.c | 4 +++
3 files changed, 55 insertions(+), 14 deletions(-)
@@ -131,19 +132,12 @@ static __init int system_trusted_keyring_init(void)*/device_initcall(system_trusted_keyring_init);-/*-*Loadthecompiled-inlistofX.509certificates.-*/-static__initintload_system_certificate_list(void)+static__initintload_cert(constu8*p,constu8*end,structkey*keyring,+unsignedlongflags){key_ref_tkey;-constu8*p,*end;size_tplen;-pr_notice("Loading compiled-in X.509 certificates\n");--p=system_certificate_list;-end=p+system_certificate_list_size;while(p<end){/* Each cert begins with an ASN.1 SEQUENCE tag and must be more*than256bytesinsize.
+}
+
+/*
+ * Load the compiled-in list of X.509 certificates.
+ */
+static __init int load_system_certificate_list(void)
+{
+ const u8 *p, *end;
+
+ pr_notice("Loading compiled-in X.509 certificates\n");
+
+#ifdef CONFIG_MODULE_SIG
+ p = system_certificate_list;
+#else
+ p = system_certificate_list + module_cert_size;
+#endif
+ end = p + system_certificate_list_size;
+ load_cert(p, end, builtin_trusted_keys, KEY_ALLOC_NOT_IN_QUOTA |
+ KEY_ALLOC_BUILT_IN |
+ KEY_ALLOC_BYPASS_RESTRICTION);
+ return 0;
The old load_system_certificate_list always returned 0 and the new
load_cert also does. You could just do 'return load_cert(p, ...)' here
and still get the 0.
@@ -111,8 +111,12 @@ static int __init __integrity_init_keyring(const unsigned int id,}else{if(id==INTEGRITY_KEYRING_PLATFORM)set_platform_trusted_keys(keyring[id]);+if(id==INTEGRITY_KEYRING_IMA)+load_module_cert(keyring[id],KEY_ALLOC_NOT_IN_QUOTA);}+pr_info("Loading key to ima keyring\n");+returnerr;}
On Thu, 2021-02-11 at 17:13 -0500, Stefan Berger wrote:
On 2/11/21 2:54 PM, Nayna Jain wrote:
quoted
Certificates being loaded onto the IMA trusted keyring must be signed by
a key on either the builtin and secondary trusted keyring.
This patch creates and includes in the kernel image an ephemeral CA
key, at build time when IMA_APPRAISE_MODSIG is enabled.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
<snip>
quoted
diff --git a/certs/Makefile b/certs/Makefile
quoted
@@ -60,14 +78,23 @@ $(obj)/signing_key.pem: $(obj)/x509.genkey @$(kecho) "### needs to be run as root, and uses a hardware random" @$(kecho) "### number generator if one is available." @$(kecho) "###"+ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)+ # Generate kernel build time CA Certificate.+ @$(Q)openssl req -new -nodes -utf8 \+ -$(CONFIG_MODULE_SIG_HASH) -days 36500 \+ -subj "/CN=Build time autogenerated kernel CA key" \+ -batch -x509 -config $(obj)/x509.genkey \+ -outform PEM -out $(CA_KEY) \+ -keyout $(CA_KEY) -extensions ca_ext \+ $($(quiet)redirect_openssl)+endif # CONFIG_IMA_APPRAISE_MODSIG $(Q)openssl req -new -nodes -utf8 \ -batch -config $(obj)/x509.genkey \ -outform PEM -out $(obj)/signing_key.csr \ -keyout $(obj)/signing_key.key -extensions myexts \ $($(quiet)redirect_openssl) $(Q)openssl x509 -req -days 36500 -in $(obj)/signing_key.csr \- -outform PEM -out $(obj)/signing_key.crt \- -signkey $(obj)/signing_key.key \+ -outform PEM -out $(obj)/signing_key.crt $(SIGNER) \ -$(CONFIG_MODULE_SIG_HASH) -extensions myexts \ -extfile $(obj)/x509.genkey \ $($(quiet)redirect_openssl)
It may make things easier (also below) if the CA was always created and
the kernel signing key was always signed by that CA rather than doing
this only in the IMA_APPRAISE_MODSIG case. Maybe someone else has an
opinion on that?
Thanks, Stefan. It would definitely simplify the code. We wanted to
minimize the code change and solicit feedback, before making such a
change.
Mimi
139789059654784:error:02001002:system library:fopen:No such file or directory:../crypto/bio/bss_file.c:69:fopen('certs/signing_key.crt','r')
139789059654784:error:2006D080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:76:
140683809875072:error:02001002:system library:fopen:No such file or directory:../crypto/bio/bss_file.c:69:fopen('certs/signing_key.crt','r')
140683809875072:error:2006D080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:76:
The "mrproper" target is still looking for build time generated keys
in the old path instead of certs/ directory.
This patch fixes the path as well removes the names of the files which
are no longer generated.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
Fixes: 28a68f828266 ("modsign: Use single PEM file for autogenerated
key")
I was curious about some of the files and how they were created in the
past but couldn't see it in the hostory of the Makefile. The above
Fixes tag seems to give the wrong commit id:
commit 28a68f828266754c2bd64b87873e8099e3f8fe0c
Author: Dave Airlie [off-list ref]
Date: Thu Oct 29 13:59:45 2020 +1000
drm/radeon/ttm: use multihop
Thanks Stefan for noticing it. I will fix this in v2.
Thanks & Regards,
- Nayna
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2021-02-12 23:48:09
On Thu, Feb 11, 2021 at 02:54:31PM -0500, Nayna Jain wrote:
The "mrproper" target is still looking for build time generated keys
in the old path instead of certs/ directory.
This patch fixes the path as well removes the names of the files which
are no longer generated.
"Fix the path..."
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
Fixes: 28a68f828266 ("modsign: Use single PEM file for autogenerated key")
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2021-02-12 23:48:55
On Thu, Feb 11, 2021 at 02:54:32PM -0500, Nayna Jain wrote:
Loading a key on the IMA trusted keyring requires the key be signed
by an existing key on the builtin or secondary trusted keyring.
Creating a Certificate Signing Request (CSR) allows the certificate
to be self-signed or signed by a CA.
This patch generates a self-signed module signing key using CSR.
@@ -60,11 +60,18 @@ $(obj)/signing_key.pem: $(obj)/x509.genkey@$(kecho)"### needs to be run as root, and uses a hardware random"@$(kecho)"### number generator if one is available."@$(kecho)"###"-$(Q)opensslreq-new-nodes-utf8-$(CONFIG_MODULE_SIG_HASH)-days36500\--batch-x509-config$(obj)/x509.genkey\--outformPEM-out$(obj)/signing_key.pem\--keyout$(obj)/signing_key.pem\+$(Q)opensslreq-new-nodes-utf8\+-batch-config$(obj)/x509.genkey\+-outformPEM-out$(obj)/signing_key.csr\+-keyout$(obj)/signing_key.key-extensionsmyexts\$($(quiet)redirect_openssl)+$(Q)opensslx509-req-days36500-in$(obj)/signing_key.csr\+-outformPEM-out$(obj)/signing_key.crt\+-signkey$(obj)/signing_key.key\+-$(CONFIG_MODULE_SIG_HASH)-extensionsmyexts\+-extfile$(obj)/x509.genkey\+$($(quiet)redirect_openssl)+@cat$(obj)/signing_key.key$(obj)/signing_key.crt>>$(obj)/signing_key.pem@$(kecho)"###"@$(kecho)"### Key pair generated."@$(kecho)"###"
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2021-02-12 23:49:26
On Thu, Feb 11, 2021 at 02:54:35PM -0500, Nayna Jain wrote:
The kernel currently only loads the kernel module signing key onto
the builtin trusted keyring. To support IMA, load the module signing
key selectively either onto builtin or ima keyring based on MODULE_SIG
~~~
IMA
or MODULE_APPRAISE_MODSIG config respectively; and loads the CA kernel
key onto builtin trusted keyring.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
@@ -131,19 +132,12 @@ static __init int system_trusted_keyring_init(void)*/device_initcall(system_trusted_keyring_init);-/*-*Loadthecompiled-inlistofX.509certificates.-*/-static__initintload_system_certificate_list(void)+static__initintload_cert(constu8*p,constu8*end,structkey*keyring,+unsignedlongflags){key_ref_tkey;-constu8*p,*end;size_tplen;-pr_notice("Loading compiled-in X.509 certificates\n");--p=system_certificate_list;-end=p+system_certificate_list_size;while(p<end){/* Each cert begins with an ASN.1 SEQUENCE tag and must be more*than256bytesinsize.
@@ -111,8 +111,12 @@ static int __init __integrity_init_keyring(const unsigned int id,}else{if(id==INTEGRITY_KEYRING_PLATFORM)set_platform_trusted_keys(keyring[id]);+if(id==INTEGRITY_KEYRING_IMA)+load_module_cert(keyring[id],KEY_ALLOC_NOT_IN_QUOTA);}+pr_info("Loading key to ima keyring\n");+returnerr;}
Loading a key on the IMA trusted keyring requires the key be signed
by an existing key on the builtin or secondary trusted keyring.
Creating a Certificate Signing Request (CSR) allows the certificate
to be self-signed or signed by a CA.
This patch generates a self-signed module signing key using CSR.
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
---
Makefile | 3 ++-
certs/Makefile | 15 +++++++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
Could you not just rename signing_key.key to signing_key.pem (as it
was before) and that would be it? Why do you need the .crt in that pem
bundle?
I had also thought so, but the PEM file contains both the private key
and the certificate. I found the reasoning in the commit "fb1179499134
modsign: Use single PEM file for autogenerated key". I addressed your
other feedback in v2, posted just now.
Thanks & Regards,
- Nayna