Preloaded revocation keys
Subsystems (3)
cover Preloaded revocation keys
The Secure Boot Forbidden Signature Database, dbx, contains a list of now revoked signatures and keys previously approved to boot with UEFI Secure Boot enabled. Currently EFI_CERT_X509_SHA256_GUID and EFI_CERT_SHA256_GUID can be preloaded (at build time) into the system blacklist keyring.
Add the ability to also preload EFI_CERT_X509_GUID dbx entries.
This series can be applied on its own; however to use preloaded revocation certificates, [1] should be applied first.
[1] https://www.spinics.net/lists/keyrings/msg08422.html
Eric Snowberg (2):
certs: Move load_system_certificate_list to a common function
certs: Add ability to preload revocation certs
certs/Kconfig | 8 +++++ certs/Makefile | 20 ++++++++++-- certs/blacklist.c | 17 ++++++++++ certs/common.c | 56 +++++++++++++++++++++++++++++++++ certs/common.h | 9 ++++++ certs/revocation_certificates.S | 21 +++++++++++++ certs/system_keyring.c | 49 ++--------------------------- scripts/Makefile | 1 + 8 files changed, 132 insertions(+), 49 deletions(-) create mode 100644 certs/common.c create mode 100644 certs/common.h create mode 100644 certs/revocation_certificates.S
base-commit: 02de58b24d2e1b2cf947d57205bd2221d897193c
Signature · 1 line
2.18.1
PATCH 1/2 certs: Move load_system_certificate_list to a common function
Move functionality within load_system_certificate_list to a common function, so it can be reused in the future.
--- certs/Makefile | 2 +- certs/common.c | 56 ++++++++++++++++++++++++++++++++++++++++++ certs/common.h | 9 +++++++ certs/system_keyring.c | 49 +++--------------------------------- 4 files changed, 69 insertions(+), 47 deletions(-) create mode 100644 certs/common.c create mode 100644 certs/common.h
certs/Makefile +1 -1
@@ -3,7 +3,7 @@ # Makefile for the linux kernel signature checking certificates. # -obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o +obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o common.o obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),"") obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_hashes.o
certs/common.c new file +56 -0
56 lines not on this page · raw message
certs/common.h new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _CERT_COMMON_H +#define _CERT_COMMON_H + +int load_certificate_list (const u8 cert_list[],const unsigned long list_size, +const struct key *keyring); + +#endif
certs/system_keyring.c +3 -46
63 lines not on this page · raw message
Signature · 1 line
2.18.1
Re: [PATCH 1/2] certs: Move load_system_certificate_list to a common function
Quoted 4 lines · Eric Snowberg
Move functionality within
load_system_certificate_listto a common function, so it can be reused in the future.Signed-off-by Eric Snowberg <[email protected]>
I rather think now rather than the future. I think this should be part of a patch set where the re-use actually happens.
Without that context, I rather not say anything about this patch. Neither an issue for me if it gets applied. This is just a guideline that I follow (in order to manage this chaos).
Looking at the code change, I do not see anything strikingly wrong in it.
/Jarkko
Re: [PATCH 1/2] certs: Move load_system_certificate_list to a common function
Quoted 11 lines · Jarkko Sakkinen
Quoted 4 lines · Eric Snowberg
Move functionality within
load_system_certificate_listto a common function, so it can be reused in the future.Signed-off-by Eric Snowberg <[email protected]>I rather think now rather than the future. I think this should be part of a patch set where the re-use actually happens.
load_certificate_list is being used in the second patch in the series [1]. It uses the now common code, to load the revocation certificates, just like the system certificates are being loaded in this patch.
Quoted 6 lines
Without that context, I rather not say anything about this patch. Neither an issue for me if it gets applied. This is just a guideline that I follow (in order to manage this chaos).
Looking at the code change, I do not see anything strikingly wrong in it.
Thanks
Jarkko Sakkinen
Acked-byRe: [PATCH 1/2] certs: Move load_system_certificate_list to a common function
Quoted 7 lines · Eric Snowberg
Quoted 7 lines · Jarkko Sakkinen
Quoted 3 lines · Eric Snowberg
Move functionality within
load_system_certificate_listto a common function, so it can be reused in the future.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Eric Snowberg <[email protected]>I rather think now rather than the future. I think this should be part of a patch set where the re-use actually happens.
load_certificate_listis being used in the second patch in the series [1]. It uses the now common code, to load the revocation certificates, just like the system certificates are being loaded in this patch.
Ugh, better to get some sleep. Double checked 2/2 and ack still holds. Sorry about this.
/Jarkko
PATCH 2/2 certs: Add ability to preload revocation certs
In reply to Eric SnowbergAdd a new Kconfig option called SYSTEM_REVOCATION_KEYS. If set, this option should be the filename of a PEM-formated file containing X.509 certificates to be included in the default blacklist keyring.
--- certs/Kconfig | 8 ++++++++ certs/Makefile | 18 ++++++++++++++++-- certs/blacklist.c | 17 +++++++++++++++++ certs/revocation_certificates.S | 21 +++++++++++++++++++++ scripts/Makefile | 1 + 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 certs/revocation_certificates.S
certs/Kconfig +8 -0
@@ -83,4 +83,12 @@ config SYSTEM_BLACKLIST_HASH_LIST wrapper to incorporate the list into the kernel. Each <hash> should be a string of hex digits. +config SYSTEM_REVOCATION_KEYS + string "X.509 certificates to be preloaded into the system blacklist keyring" + depends on SYSTEM_BLACKLIST_KEYRING + help + If set, this option should be the filename of a PEM-formatted file + containing X.509 certificates to be included in the default blacklist + keyring. + endmenu
certs/Makefile +16 -2
@@ -4,7 +4,7 @@ # obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o common.o -obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o +obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o revocation_certificates.o common.o ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),"") obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_hashes.o else
@@ -29,7 +29,7 @@ $(obj)/x509_certificate_list: scripts/extract-cert $(SYSTEM_TRUSTED_KEYS_SRCPREF $(call if_changed,extract_certs,$(SYSTEM_TRUSTED_KEYS_SRCPREFIX)$(CONFIG_SYSTEM_TRUSTED_KEYS)) endif # CONFIG_SYSTEM_TRUSTED_KEYRING -clean-files := x509_certificate_list .x509.list +clean-files := x509_certificate_list .x509.list x509_revocation_list ifeq ($(CONFIG_MODULE_SIG),y) ###############################################################################
@@ -104,3 +104,17 @@ targets += signing_key.x509 $(obj)/signing_key.x509: scripts/extract-cert $(X509_DEP) FORCE $(call if_changed,extract_certs,$(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY)) endif # CONFIG_MODULE_SIG + +ifeq ($(CONFIG_SYSTEM_BLACKLIST_KEYRING),y) + +$(eval $(call config_filename,SYSTEM_REVOCATION_KEYS)) + +$(obj)/revocation_certificates.o: $(obj)/x509_revocation_list + +quiet_cmd_extract_certs = EXTRACT_CERTS $(patsubst "%",%,$(2)) + cmd_extract_certs = scripts/extract-cert $(2) $@ + +targets += x509_revocation_list +$(obj)/x509_revocation_list: scripts/extract-cert $(SYSTEM_REVOCATION_KEYS_SRCPREFIX)$(SYSTEM_REVOCATION_KEYS_FILENAME) FORCE + $(call if_changed,extract_certs,$(SYSTEM_REVOCATION_KEYS_SRCPREFIX)$(CONFIG_SYSTEM_REVOCATION_KEYS)) +endif
certs/blacklist.c +17 -0
@@ -16,9 +16,13 @@#include <linux/seq_file.h> #include <keys/system_keyring.h> #include "blacklist.h" +#include "common.h" static struct key *blacklist_keyring; +extern __initconst const u8 revocation_certificate_list[]; +extern __initconst const unsigned long revocation_certificate_list_size; +/* * The description must be a type prefix, a colon and then an even number of * hex digits. The hash is kept in the description.
@@ -177,3 +181,16 @@ static int __init blacklist_init(void)* Must be initialised before we try and load the keys into the keyring. */ device_initcall (blacklist_init); + +/* +* Load the compiled-in list of revocation X.509 certificates. +*/ +static __init int load_revocation_certificate_list (void ) +{ +if (revocation_certificate_list_size) +pr_notice ("Loading compiled-in revocation X.509 certificates\n" ); + +return load_certificate_list (revocation_certificate_list, revocation_certificate_list_size, + blacklist_keyring); +} +late_initcall (load_revocation_certificate_list);
certs/revocation_certificates.S new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include <linux/export.h> +#include <linux/init.h> + + __INITRODATA + + .align 8 + .globl revocation_certificate_list +revocation_certificate_list: +__revocation_list_start: + .incbin "certs/x509_revocation_list" +__revocation_list_end: + + .align 8 + .globl revocation_certificate_list_size +revocation_certificate_list_size: +#ifdef CONFIG_64BIT + .quad __revocation_list_end - __revocation_list_start +#else + .long __revocation_list_end - __revocation_list_start +#endif
scripts/Makefile +1 -0
@@ -11,6 +11,7 @@ hostprogs-always-$(CONFIG_ASN1) += asn1_compiler hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file hostprogs-always-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert + hostprogs-always-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += extract-cert HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
Signature · 1 line
2.18.1
Re: [PATCH 2/2] certs: Add ability to preload revocation certs
Quoted 5 lines · Eric Snowberg
Add a new
Kconfigoption calledSYSTEM_REVOCATION_KEYS. If set, this option should be the filename of a PEM-formated file containing X.509 certificates to be included in the default blacklist keyring.Signed-off-by Eric Snowberg <[email protected]>
/Jarkko