Make detecting the secure boot status integrity-wide
cover Make detecting the secure boot status integrity-wide
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA arch_ima_get_secureboot function. Make arch_ima_get_secureboot integrity-wide.
Coiby Xu (3):
integrity: Make arch_ima_get_secureboot integrity-wide
evm: Don't enable fix mode when secure boot is enabled
s390: Drop unnecessary CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT
arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 2 +- arch/s390/kernel/Makefile | 2 +- arch/s390/kernel/ima_arch.c | 14 ----- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/evm/evm_main.c | 24 +++++--- security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 22 files changed, 128 insertions(+), 87 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c delete mode 100644 arch/s390/kernel/ima_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.c
base-commit: 7f98ab9da046865d57c102fd3ca9669a29845f67
Signature · 1 line
2.52.0
PATCH 1/3 integrity: Make arch_ima_get_secureboot integrity-wide
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA arch_ima_get_secureboot function. Refactor the secure boot status check into a general, integrity-wide function named arch_integrity_get_secureboot.
Define a new Kconfig option CONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existing IMA_SECURE_AND_OR_TRUSTED_BOOT Kconfig loads the architecture specific IMA policy based on the refactored secure boot status code.
--- arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 1 + arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 21 files changed, 111 insertions(+), 70 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.c
arch/arm64/Kconfig +1 -0
@@ -2427,6 +2427,7 @@ config EFI select EFI_STUB select EFI_GENERIC_STUB imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOT default y help This option provides support for runtime services provided
arch/powerpc/Kconfig +1 -0
@@ -1058,6 +1058,7 @@ config PPC_SECURE_BOOT depends on PPC_POWERNV || PPC_PSERIES depends on IMA_ARCH_POLICY imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOT select PSERIES_PLPKS if PPC_PSERIES help Systems with firmware secure boot enabled need to define security
arch/powerpc/kernel/Makefile +1 -1
@@ -168,7 +168,7 @@ ifneq ($(CONFIG_PPC_POWERNV)$(CONFIG_PPC_SVM),) obj-y += ucall.o endif -obj-$(CONFIG_PPC_SECURE_BOOT) += secure_boot.o ima_arch.o secvar-ops.o +obj-$(CONFIG_PPC_SECURE_BOOT) += secure_boot.o ima_arch.o integrity_sb_arch.o secvar-ops.o obj-$(CONFIG_PPC_SECVAR_SYSFS) += secvar-sysfs.o # Disable GCOV, KCOV & sanitizers in odd or sensitive code
arch/powerpc/kernel/ima_arch.c +0 -5
@@ -7,11 +7,6 @@#include <linux/ima.h> #include <asm/secure_boot.h> -bool arch_ima_get_secureboot (void ) -{ -return is_ppc_secureboot_enabled (); -} -/* * The "secure_rules" are enabled only on "secureboot" enabled systems. * These rules verify the file signatures against known good values.
arch/powerpc/kernel/integrity_sb_arch.c new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2019 IBM Corporation +* Author: Nayna Jain +*/ + +#include <linux/integrity.h> +#include <asm/secure_boot.h> + +bool arch_integrity_get_secureboot (void ) +{ +return is_ppc_secureboot_enabled (); +}
arch/s390/Kconfig +1 -0
@@ -78,6 +78,7 @@ config S390 # Note: keep this list sorted alphabetically # imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOT select ALTERNATE_USER_ADDRESS_SPACE select ARCH_32BIT_USTAT_F_TINODE select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
arch/s390/kernel/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o obj-$(CONFIG_CERT_STORE) += cert_store.o obj-$(CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT) += ima_arch.o +obj-$(CONFIG_INTEGRITY_SECURE_BOOT) += integrity_sb_arch.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf.o perf_cpum_sf.o
arch/s390/kernel/ima_arch.c +0 -6
@@ -1,12 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/ima.h> -#include <asm/boot_data.h> - -bool arch_ima_get_secureboot (void ) -{ -return ipl_secure_flag; -}const char *const *arch_get_ima_policy (void ) {
arch/s390/kernel/integrity_sb_arch.c new file +9 -0
@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/integrity.h> +#include <asm/boot_data.h> + +bool arch_integrity_get_secureboot (void ) +{ +return ipl_secure_flag; +}
arch/x86/Kconfig +1 -0
@@ -330,6 +330,7 @@ config X86 select FUNCTION_ALIGNMENT_16B if X86_64 || X86_ALIGNMENT_16 select FUNCTION_ALIGNMENT_4B imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI + imply INTEGRITY_SECURE_BOOT if EFI select HAVE_DYNAMIC_FTRACE_NO_PATCHABLE select ARCH_SUPPORTS_PT_RECLAIM if X86_64 select ARCH_SUPPORTS_SCHED_SMT if SMP
arch/x86/include/asm/efi.h +2 -2
@@ -401,9 +401,9 @@ extern int __init efi_memmap_split_count(efi_memory_desc_t *md,extern void __init efi_memmap_insert (struct efi_memory_map *old_memmap,void *buf,struct efi_mem_range *mem); -extern enum efi_secureboot_mode __x86_ima_efi_boot_mode (void ); +enum efi_secureboot_mode __x86_integrity_efi_boot_mode (void ); -#define arch_ima_efi_boot_mode __x86_ima_efi_boot_mode() +#define arch_integrity_efi_boot_mode __x86_integrity_efi_boot_mode()#ifdef CONFIG_EFI_RUNTIME_MAP int efi_get_runtime_map_size (void );
arch/x86/platform/efi/efi.c +1 -1
@@ -921,7 +921,7 @@ umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)return attr->mode; } -enum efi_secureboot_mode __x86_ima_efi_boot_mode (void ) +enum efi_secureboot_mode __x86_integrity_efi_boot_mode (void ) {return boot_params.secure_boot; }
include/linux/ima.h +1 -6
@@ -11,6 +11,7 @@#include <linux/fs.h> #include <linux/security.h> #include <linux/kexec.h> +#include <linux/integrity.h> #include <crypto/hash_info.h> struct linux_binprm ;
@@ -72,14 +73,8 @@ int __init ima_get_kexec_buffer(void **addr, size_t *size);#endif #ifdef CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT -extern bool arch_ima_get_secureboot (void );extern const char *const *arch_get_ima_policy (void );#else -static inline bool arch_ima_get_secureboot (void ) -{ -return false; -} -static inline const char *const *arch_get_ima_policy (void ) {return NULL ;
include/linux/integrity.h +8 -0
@@ -61,5 +61,13 @@ integrity_inode_attrs_changed(const struct integrity_inode_attributes *attrs, !inode_eq_iversion(inode, attrs->version)); } +#ifdef CONFIG_INTEGRITY_SECURE_BOOT +bool arch_integrity_get_secureboot (void ); +#else +static inline bool arch_integrity_get_secureboot (void ) +{ +return false; +} +#endif #endif /* _LINUX_INTEGRITY_H */
security/integrity/Kconfig +6 -0
@@ -97,6 +97,12 @@ config INTEGRITY_CA_MACHINE_KEYRING_MAX will not be loaded. The remaining MOK keys are loaded into the .platform keyring. +config INTEGRITY_SECURE_BOOT + bool + help + This option is selected by architectures to provide secure boot + related helper functions. + config LOAD_UEFI_KEYS depends on INTEGRITY_PLATFORM_KEYRING depends on EFI
security/integrity/Makefile +3 -0
@@ -18,6 +18,9 @@ integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o integrity-$(CONFIG_LOAD_PPC_KEYS) += platform_certs/efi_parser.o \ platform_certs/load_powerpc.o \ platform_certs/keyring_handler.o +ifeq ($(CONFIG_EFI),y) +integrity-$(CONFIG_INTEGRITY_SECURE_BOOT) += efi_secureboot.o +endif # The relative order of the 'ima' and 'evm' LSMs depends on the order below. obj-$(CONFIG_IMA) += ima/ obj-$(CONFIG_EVM) += evm/
security/integrity/efi_secureboot.c new file +56 -0
56 lines not on this page · raw message
security/integrity/ima/ima_appraise.c +1 -1
@@ -27,7 +27,7 @@ core_param(ima_appraise, ima_appraise_cmdline_default, charp, 0);void __init ima_appraise_parse_cmdline (void ) {const char *str = ima_appraise_cmdline_default; -bool sb_state =arch_ima_get_secureboot (); +bool sb_state =arch_integrity_get_secureboot ();int appraisal_state = ima_appraise;if (!str)
security/integrity/ima/ima_efi.c +2 -45
61 lines not on this page · raw message
security/integrity/ima/ima_main.c +2 -2
@@ -949,8 +949,8 @@ static int ima_load_data(enum kernel_load_data_id id, bool contents)switch (id) {case LOADING_KEXEC_IMAGE : -if (IS_ENABLED (CONFIG_KEXEC_SIG ) - &&arch_ima_get_secureboot ()) { +if (IS_ENABLED (CONFIG_KEXEC_SIG ) && +arch_integrity_get_secureboot ()) {pr_err ("impossible to appraise a kernel image without a file descriptor; try using kexec_file_load syscall.\n" );return -EACCES ; }
security/integrity/platform_certs/load_uefi.c +1 -1
@@ -212,7 +212,7 @@ static int __init load_uefi_certs(void) }/* the MOK/MOKx can not be trusted when secure boot is disabled */ -if (!arch_ima_get_secureboot ()) +if (!arch_integrity_get_secureboot ())return 0 ; mokx =get_cert_list (L"MokListXRT" , &mok_var, &mokxsize, &status);
Signature · 1 line
2.52.0
Re: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 5 lines · Coiby Xu
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA
arch_ima_get_securebootfunction. Refactor the secure boot status check into a general, integrity-wide function namedarch_integrity_get_secureboot.
Quoted 8 lines
Define a new
KconfigoptionCONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existingIMA_SECURE_AND_OR_TRUSTED_BOOTKconfigloads the architecture specific IMA policy based on the refactored secure boot status code.Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>
Thanks, Coiby!
Ard Biesheuvel
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
In reply to Coiby XuQuoted 46 lines · Coiby Xu
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA
arch_ima_get_securebootfunction. Refactor the secure boot status check into a general, integrity-wide function namedarch_integrity_get_secureboot.Define a new
KconfigoptionCONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existingIMA_SECURE_AND_OR_TRUSTED_BOOTKconfigloads the architecture specific IMA policy based on the refactored secure boot status code.Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 1 + arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 21 files changed, 111 insertions(+), 70 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.carch/arm64/Kconfig +0
-0
arch/arm64/Kconfig config EFI · line 2430
Quoted 4 lines
arch/arm64/Kconfig +1
-0@@ -2427,6 +2427,7 @@ config EFI select EFI_STUB select EFI_GENERIC_STUB imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOT
This allows both to be en/disabled individually, which I don't think is what we want. It also results in more churn across the arch-specific Kconfigs than needed.
Wouldn't it be better if IMA_SECURE_AND_OR_TRUSTED_BOOT 'select'ed INTEGRITY_SECURE_BOOT in its Kconfig definition?
Mimi Zohar
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 56 lines · Ard Biesheuvel
Quoted 46 lines · Coiby Xu
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA
arch_ima_get_securebootfunction. Refactor the secure boot status check into a general, integrity-wide function namedarch_integrity_get_secureboot.Define a new
KconfigoptionCONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existingIMA_SECURE_AND_OR_TRUSTED_BOOTKconfigloads the architecture specific IMA policy based on the refactored secure boot status code.Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 1 + arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 21 files changed, 111 insertions(+), 70 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.carch/arm64/Kconfig +0
-0arch/arm64/Kconfig config EFI · line 2430
Quoted 4 lines
arch/arm64/Kconfig +1
-0@@ -2427,6 +2427,7 @@ config EFI select EFI_STUB select EFI_GENERIC_STUB imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOTThis allows both to be en/disabled individually, which I don't think is what we want. It also results in more churn across the arch-specific Kconfigs than needed.
Quoted 2 lines
Wouldn't it be better if
IMA_SECURE_AND_OR_TRUSTED_BOOT'select'edINTEGRITY_SECURE_BOOTin itsKconfigdefinition?
As much as possible, EVM (and other LSMs) shouldn't be dependent on another LSM, in this case IMA, being configured.
Ard Biesheuvel
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 58 lines · Mimi Zohar
Quoted 56 lines · Ard Biesheuvel
Quoted 46 lines · Coiby Xu
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA
arch_ima_get_securebootfunction. Refactor the secure boot status check into a general, integrity-wide function namedarch_integrity_get_secureboot.Define a new
KconfigoptionCONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existingIMA_SECURE_AND_OR_TRUSTED_BOOTKconfigloads the architecture specific IMA policy based on the refactored secure boot status code.Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 1 + arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 21 files changed, 111 insertions(+), 70 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.carch/arm64/Kconfig +0
-0arch/arm64/Kconfig config EFI · line 2430
Quoted 4 lines
arch/arm64/Kconfig +1
-0@@ -2427,6 +2427,7 @@ config EFI select EFI_STUB select EFI_GENERIC_STUB imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOTThis allows both to be en/disabled individually, which I don't think is what we want. It also results in more churn across the arch-specific Kconfigs than needed.
Quoted 5 lines
Quoted 2 lines
Wouldn't it be better if
IMA_SECURE_AND_OR_TRUSTED_BOOT'select'edINTEGRITY_SECURE_BOOTin itsKconfigdefinition?As much as possible, EVM (and other LSMs) shouldn't be dependent on another LSM, in this case IMA, being configured.
Sure, but that is not my point.
This arrangement allows for IMA_SECURE_AND_OR_TRUSTED_BOOT to be enabled without INTEGRITY_SECURE_BOOT, resulting in the stub implementation of arch_integrity_get_secureboot() being used, which always returns false.
Mimi Zohar
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 65 lines · Ard Biesheuvel
Quoted 58 lines · Mimi Zohar
Quoted 56 lines · Ard Biesheuvel
Quoted 46 lines · Coiby Xu
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA
arch_ima_get_securebootfunction. Refactor the secure boot status check into a general, integrity-wide function namedarch_integrity_get_secureboot.Define a new
KconfigoptionCONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existingIMA_SECURE_AND_OR_TRUSTED_BOOTKconfigloads the architecture specific IMA policy based on the refactored secure boot status code.Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 1 + arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 21 files changed, 111 insertions(+), 70 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.carch/arm64/Kconfig +0
-0arch/arm64/Kconfig config EFI · line 2430
Quoted 4 lines
arch/arm64/Kconfig +1
-0@@ -2427,6 +2427,7 @@ config EFI select EFI_STUB select EFI_GENERIC_STUB imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOTThis allows both to be en/disabled individually, which I don't think is what we want. It also results in more churn across the arch-specific Kconfigs than needed.
Quoted 5 lines
Quoted 2 lines
Wouldn't it be better if
IMA_SECURE_AND_OR_TRUSTED_BOOT'select'edINTEGRITY_SECURE_BOOTin itsKconfigdefinition?As much as possible, EVM (and other LSMs) shouldn't be dependent on another LSM, in this case IMA, being configured.
Quoted 6 lines
Sure, but that is not my point.
This arrangement allows for
IMA_SECURE_AND_OR_TRUSTED_BOOTto be enabled withoutINTEGRITY_SECURE_BOOT, resulting in the stub implementation ofarch_integrity_get_secureboot()being used, which always returns false.
I understand your concern, but instead of "select"ing INTEGRITY_SECURE_BOOT from IMA_SECURE_AND_OR_TRUSTED_BOOT, how making IMA_SECURE_AND_OR_TRUSTED_BOOT dependent on both IMA_ARCH_POLICY and INTEGRITY_SECURE_BOOT.
Including the "imply INTEGRITY_SECURE_BOOT" here in the arch Kconfig allows EVM to query the secure boot state without relying on IMA_SECURE_AND_OR_TRUSTED_BOOT being configured.
Ard Biesheuvel
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 69 lines · Mimi Zohar
Quoted 67 lines · Ard Biesheuvel
Quoted 58 lines · Mimi Zohar
Quoted 56 lines · Ard Biesheuvel
Quoted 46 lines · Coiby Xu
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA
arch_ima_get_securebootfunction. Refactor the secure boot status check into a general, integrity-wide function namedarch_integrity_get_secureboot.Define a new
KconfigoptionCONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existingIMA_SECURE_AND_OR_TRUSTED_BOOTKconfigloads the architecture specific IMA policy based on the refactored secure boot status code.Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 1 + arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 21 files changed, 111 insertions(+), 70 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.carch/arm64/Kconfig +0
-0arch/arm64/Kconfig config EFI · line 2430
Quoted 4 lines
arch/arm64/Kconfig +1
-0@@ -2427,6 +2427,7 @@ config EFI select EFI_STUB select EFI_GENERIC_STUB imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOTThis allows both to be en/disabled individually, which I don't think is what we want. It also results in more churn across the arch-specific Kconfigs than needed.
Quoted 5 lines
Quoted 2 lines
Wouldn't it be better if
IMA_SECURE_AND_OR_TRUSTED_BOOT'select'edINTEGRITY_SECURE_BOOTin itsKconfigdefinition?As much as possible, EVM (and other LSMs) shouldn't be dependent on another LSM, in this case IMA, being configured.
Sure, but that is not my point.
Quoted 9 lines
Quoted 4 lines
This arrangement allows for
IMA_SECURE_AND_OR_TRUSTED_BOOTto be enabled withoutINTEGRITY_SECURE_BOOT, resulting in the stub implementation ofarch_integrity_get_secureboot()being used, which always returns false.I understand your concern, but instead of "select"ing
INTEGRITY_SECURE_BOOTfromIMA_SECURE_AND_OR_TRUSTED_BOOT, how makingIMA_SECURE_AND_OR_TRUSTED_BOOTdependent on bothIMA_ARCH_POLICYandINTEGRITY_SECURE_BOOT.
Given that INTEGRITY_SECURE_BOOT has no dependencies of its own, afaict, selecting it is the least disruptive option, as otherwise, existing configs will disable IMA_SECURE_AND_OR_TRUSTED_BOOT as the kernel is being upgraded. But conceptually, I agree that they are equivalent.
Quoted 3 lines
Including the "imply
INTEGRITY_SECURE_BOOT" here in the archKconfigallows EVM to query the secure boot state without relying onIMA_SECURE_AND_OR_TRUSTED_BOOTbeing configured.
Yes, I understand that this is the whole point of the exercise. But 'imply' should be used with care, and in this case, implying both from CONFIG_EFI really makes little sense. INTEGRITY_SECURE_BOOT should be selected by options that need the functionality, not 'implied' by options that might provide it.
Mimi Zohar
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 90 lines · Ard Biesheuvel
Quoted 69 lines · Mimi Zohar
Quoted 67 lines · Ard Biesheuvel
Quoted 58 lines · Mimi Zohar
Quoted 56 lines · Ard Biesheuvel
Quoted 46 lines · Coiby Xu
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA
arch_ima_get_securebootfunction. Refactor the secure boot status check into a general, integrity-wide function namedarch_integrity_get_secureboot.Define a new
KconfigoptionCONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existingIMA_SECURE_AND_OR_TRUSTED_BOOTKconfigloads the architecture specific IMA policy based on the refactored secure boot status code.Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 1 + arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 21 files changed, 111 insertions(+), 70 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.carch/arm64/Kconfig +0
-0arch/arm64/Kconfig config EFI · line 2430
Quoted 4 lines
arch/arm64/Kconfig +1
-0@@ -2427,6 +2427,7 @@ config EFI select EFI_STUB select EFI_GENERIC_STUB imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOTThis allows both to be en/disabled individually, which I don't think is what we want. It also results in more churn across the arch-specific Kconfigs than needed.
Quoted 5 lines
Quoted 2 lines
Wouldn't it be better if
IMA_SECURE_AND_OR_TRUSTED_BOOT'select'edINTEGRITY_SECURE_BOOTin itsKconfigdefinition?As much as possible, EVM (and other LSMs) shouldn't be dependent on another LSM, in this case IMA, being configured.
Sure, but that is not my point.
Quoted 9 lines
Quoted 4 lines
This arrangement allows for
IMA_SECURE_AND_OR_TRUSTED_BOOTto be enabled withoutINTEGRITY_SECURE_BOOT, resulting in the stub implementation ofarch_integrity_get_secureboot()being used, which always returns false.I understand your concern, but instead of "select"ing
INTEGRITY_SECURE_BOOTfromIMA_SECURE_AND_OR_TRUSTED_BOOT, how makingIMA_SECURE_AND_OR_TRUSTED_BOOTdependent on bothIMA_ARCH_POLICYandINTEGRITY_SECURE_BOOT.Given that
INTEGRITY_SECURE_BOOThas no dependencies of its own, afaict, selecting it is the least disruptive option, as otherwise, existing configs will disableIMA_SECURE_AND_OR_TRUSTED_BOOTas the kernel is being upgraded. But conceptually, I agree that they are equivalent.Quoted 3 lines
Including the "imply
INTEGRITY_SECURE_BOOT" here in the archKconfigallows EVM to query the secure boot state without relying onIMA_SECURE_AND_OR_TRUSTED_BOOTbeing configured.
Quoted 5 lines
Yes, I understand that this is the whole point of the exercise. But 'imply' should be used with care, and in this case, implying both from
CONFIG_EFIreally makes little sense.INTEGRITY_SECURE_BOOTshould be selected by options that need the functionality, not 'implied' by options that might provide it.
As not all arch's implement arch_integrity_get_secureboot, the definition in include/linux/integrity.h would need to be updated. Something like:
-#ifdef CONFIG_INTEGRITY_SECURE_BOOT
+#if (defined(CONFIG_INTEGRITY_SECURE_BOOT) && \
+ (defined(CONFIG_X86) && defined(CONFIG_EFI)) || defined(CONFIG_S390) \
+ || defined(CONFIG_PPC_SECURE_BOOT))
Then IMA_SECURE_AND_OR_TRUSTED_BOOT and EVM could select INTEGRITY_SECURE_BOOT, as suggested.
Mimi
Re: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 1 line · Mimi Zohar
On Fri, 2026-01-16 at 18:27 +0100, Ard Biesheuvel wrote:
Hi Ard and Mimi,
Thanks for your discussion on improving the patch!
Quoted 68 lines
Quoted 68 lines · Mimi Zohar
Quoted 67 lines · Ard Biesheuvel
Quoted 65 lines · Mimi Zohar
Quoted 63 lines · Ard Biesheuvel
Quoted 56 lines · Coiby Xu
Quoted 46 lines
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA
arch_ima_get_securebootfunction. Refactor the secure boot status check into a general, integrity-wide function namedarch_integrity_get_secureboot.Define a new
KconfigoptionCONFIG_INTEGRITY_SECURE_BOOT, which is automatically configured by the supported architectures. The existingIMA_SECURE_AND_OR_TRUSTED_BOOTKconfigloads the architecture specific IMA policy based on the refactored secure boot status code.Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/integrity_sb_arch.c | 13 +++++ arch/s390/Kconfig | 1 + arch/s390/kernel/Makefile | 1 + arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/integrity_sb_arch.c | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/integrity.h | 8 +++ security/integrity/Kconfig | 6 ++ security/integrity/Makefile | 3 + security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 4 +- security/integrity/platform_certs/load_uefi.c | 2 +- 21 files changed, 111 insertions(+), 70 deletions(-) create mode 100644 arch/powerpc/kernel/integrity_sb_arch.c create mode 100644 arch/s390/kernel/integrity_sb_arch.c create mode 100644 security/integrity/efi_secureboot.carch/arm64/Kconfig +0
-0arch/arm64/Kconfig config EFI · line 2430
Quoted 4 lines
arch/arm64/Kconfig +1
-0@@ -2427,6 +2427,7 @@ config EFI select EFI_STUB select EFI_GENERIC_STUB imply IMA_SECURE_AND_OR_TRUSTED_BOOT + imply INTEGRITY_SECURE_BOOTThis allows both to be en/disabled individually, which I don't think is what we want. It also results in more churn across the arch-specific Kconfigs than needed.
Quoted 2 lines
Wouldn't it be better if
IMA_SECURE_AND_OR_TRUSTED_BOOT'select'edINTEGRITY_SECURE_BOOTin itsKconfigdefinition?As much as possible, EVM (and other LSMs) shouldn't be dependent on another LSM, in this case IMA, being configured.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Sure, but that is not my point.
This arrangement allows for
IMA_SECURE_AND_OR_TRUSTED_BOOTto be enabled withoutINTEGRITY_SECURE_BOOT, resulting in the stub implementation ofarch_integrity_get_secureboot()being used, which always returns false.
Since both INTEGRITY_SECURE_BOOT and IMA_SECURE_AND_OR_TRUSTED_BOOT don't define a prompt, they are not user-configurable and will always be enable/disabled together with arch-specific secure boot feature. So despite the "imply" key word, the case where IMA_SECURE_AND_OR_TRUSTED_BOOT is enabled whereas INTEGRITY_SECURE_BOOT is disabled won't happen.
But I agree an arch may not care much about INTEGRITY_SECURE_BOOT so it may be a churn. So limiting it to the scope of the integrity subsystem can be a better idea.
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
I understand your concern, but instead of "select"ing
INTEGRITY_SECURE_BOOTfromIMA_SECURE_AND_OR_TRUSTED_BOOT, how makingIMA_SECURE_AND_OR_TRUSTED_BOOTdependent on bothIMA_ARCH_POLICYandINTEGRITY_SECURE_BOOT.Given that
INTEGRITY_SECURE_BOOThas no dependencies of its own, afaict, selecting it is the least disruptive option, as otherwise, existing configs will disableIMA_SECURE_AND_OR_TRUSTED_BOOTas the kernel is being upgraded. But conceptually, I agree that they are equivalent.
As already pointed out on by Mimi, INTEGRITY_SECURE_BOOT depend on arch-specific secure boot feature. So we can't say INTEGRITY_SECURE_BOOT has no dependencies.
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Including the "imply
INTEGRITY_SECURE_BOOT" here in the archKconfigallows EVM to query the secure boot state without relying onIMA_SECURE_AND_OR_TRUSTED_BOOTbeing configured.Yes, I understand that this is the whole point of the exercise. But 'imply' should be used with care, and in this case, implying both from
CONFIG_EFIreally makes little sense.INTEGRITY_SECURE_BOOTshould be selected by options that need the functionality, not 'implied' by options that might provide it.
But again I agree INTEGRITY_SECURE_BOOT should "not 'implied' by options that might provide it".
Quoted 11 lines
As not all arch's implement
arch_integrity_get_secureboot, the definition ininclude/linux/integrity.hwould need to be updated. Something like:(quoted diff) +3
-1-#ifdef CONFIG_INTEGRITY_SECURE_BOOT +#if (defined(CONFIG_INTEGRITY_SECURE_BOOT) && \ + (defined(CONFIG_X86) && defined(CONFIG_EFI)) || defined(CONFIG_S390) \ + || defined(CONFIG_PPC_SECURE_BOOT))Then
IMA_SECURE_AND_OR_TRUSTED_BOOTand EVM could selectINTEGRITY_SECURE_BOOT, as suggested.
Since INTEGRITY_SECURE_BOOT has a dependency, select doesn't seem to be a good choice. If EVM does select INTEGRITY_SECURE_BOOT, INTEGRITY_SECURE_BOOT will be enabled even if arch-specific secure boot feature is disabled and this can lead to a building failure. How about always enabling INTEGRITY_SECURE_BOOT when secure boot feature is enabled and also making IMA_SECURE_AND_OR_TRUSTED_BOOT depend on INTEGRITY_SECURE_BOOT?
security/integrity/Kconfig +7 -0
@@ -97,6 +97,13 @@ config INTEGRITY_CA_MACHINE_KEYRING_MAX will not be loaded. The remaining MOK keys are loaded into the .platform keyring. +config INTEGRITY_SECURE_BOOT + def_bool y + depends on EFI || PPC_SECURE_BOOT || S390 + help + Provide secure boot related helper functions like querying the + secure boot status. +
security/integrity/ima/Kconfig +1 -0
@@ -311,6 +311,7 @@ config IMA_QUEUE_EARLY_BOOT_KEYS config IMA_SECURE_AND_OR_TRUSTED_BOOT bool depends on IMA_ARCH_POLICY + depends on INTEGRITY_SECURE_BOOT
Another idea is make a tree-wide arch_get_secureboot i.e. to move current arch_ima_get_secureboot code to arch-specific secure boot implementation. By this way, there will no need for a new Kconfig option INTEGRITY_SECURE_BOOT. But I'm not sure if there is any unforeseen concern.
Signature · 2 lines
Best regards, Coiby
Mimi Zohar
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 11 lines · Coiby Xu
security/integrity/ima/Kconfig +1
-0@@ -311,6 +311,7 @@ config IMA_QUEUE_EARLY_BOOT_KEYS config IMA_SECURE_AND_OR_TRUSTED_BOOT bool depends on IMA_ARCH_POLICY + depends on INTEGRITY_SECURE_BOOT
Quoted 5 lines
Another idea is make a tree-wide
arch_get_securebooti.e. to move currentarch_ima_get_securebootcode to arch-specific secure boot implementation. By this way, there will no need for a newKconfigoptionINTEGRITY_SECURE_BOOT. But I'm not sure if there is any unforeseen concern.
Originally basing IMA policy on the secure boot mode was an exception. As long as making it public isn't an issue any longer, this sounds to me. Ard, Dave, do you have any issues with replacing arch_ima_get_secureboot() with arch_get_secureboot()?
Ard Biesheuvel
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 14 lines · Mimi Zohar
Quoted 11 lines · Coiby Xu
security/integrity/ima/Kconfig +1
-0@@ -311,6 +311,7 @@ config IMA_QUEUE_EARLY_BOOT_KEYS config IMA_SECURE_AND_OR_TRUSTED_BOOT bool depends on IMA_ARCH_POLICY + depends on INTEGRITY_SECURE_BOOT
Quoted 10 lines
Quoted 5 lines
Another idea is make a tree-wide
arch_get_securebooti.e. to move currentarch_ima_get_securebootcode to arch-specific secure boot implementation. By this way, there will no need for a newKconfigoptionINTEGRITY_SECURE_BOOT. But I'm not sure if there is any unforeseen concern.Originally basing IMA policy on the secure boot mode was an exception. As long as making it public isn't an issue any longer, this sounds to me. Ard, Dave, do you have any issues with replacing
arch_ima_get_secureboot()witharch_get_secureboot()?
I don't see an issue with that. If there is a legitimate need to determine this even if IMA is not enabled, then this makes sense.
Re: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 26 lines · Ard Biesheuvel
Quoted 14 lines · Mimi Zohar
Quoted 11 lines · Coiby Xu
security/integrity/ima/Kconfig +1
-0@@ -311,6 +311,7 @@ config IMA_QUEUE_EARLY_BOOT_KEYS config IMA_SECURE_AND_OR_TRUSTED_BOOT bool depends on IMA_ARCH_POLICY + depends on INTEGRITY_SECURE_BOOTQuoted 10 lines
Quoted 5 lines
Another idea is make a tree-wide
arch_get_securebooti.e. to move currentarch_ima_get_securebootcode to arch-specific secure boot implementation. By this way, there will no need for a newKconfigoptionINTEGRITY_SECURE_BOOT. But I'm not sure if there is any unforeseen concern.Originally basing IMA policy on the secure boot mode was an exception. As long as making it public isn't an issue any longer, this sounds to me. Ard, Dave, do you have any issues with replacing
arch_ima_get_secureboot()witharch_get_secureboot()?
Quoted 2 lines
I don't see an issue with that. If there is a legitimate need to determine this even if IMA is not enabled, then this makes sense.
Thanks for the confirmation! Here's the updated patch
https://github.com/coiby/linux/commit/c222c1d08d90ef1ec85ef81ece90afc9efde7937.patch
If there is no objection, I'll send v2.
Signature · 2 lines
Best regards, Coiby
Mimi Zohar
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
In reply to Ard BiesheuvelQuoted 26 lines · Ard Biesheuvel
Quoted 14 lines · Mimi Zohar
Quoted 11 lines · Coiby Xu
security/integrity/ima/Kconfig +1
-0@@ -311,6 +311,7 @@ config IMA_QUEUE_EARLY_BOOT_KEYS config IMA_SECURE_AND_OR_TRUSTED_BOOT bool depends on IMA_ARCH_POLICY + depends on INTEGRITY_SECURE_BOOTQuoted 10 lines
Quoted 5 lines
Another idea is make a tree-wide
arch_get_securebooti.e. to move currentarch_ima_get_securebootcode to arch-specific secure boot implementation. By this way, there will no need for a newKconfigoptionINTEGRITY_SECURE_BOOT. But I'm not sure if there is any unforeseen concern.Originally basing IMA policy on the secure boot mode was an exception. As long as making it public isn't an issue any longer, this sounds to me. Ard, Dave, do you have any issues with replacing
arch_ima_get_secureboot()witharch_get_secureboot()?
Quoted 2 lines
I don't see an issue with that. If there is a legitimate need to determine this even if IMA is not enabled, then this makes sense.
Ard, Dave -
FYI, Coiby posted v3 of this patch set[1], which is queued in the next- integrity-testing branch[2].
[1]
https://lore.kernel.org/linux-integrity/[email protected]/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git/
Mimi
Ard Biesheuvel
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Quoted 32 lines · Mimi Zohar
Quoted 26 lines · Ard Biesheuvel
Quoted 14 lines · Mimi Zohar
Quoted 11 lines · Coiby Xu
security/integrity/ima/Kconfig +1
-0@@ -311,6 +311,7 @@ config IMA_QUEUE_EARLY_BOOT_KEYS config IMA_SECURE_AND_OR_TRUSTED_BOOT bool depends on IMA_ARCH_POLICY + depends on INTEGRITY_SECURE_BOOTQuoted 10 lines
Quoted 5 lines
Another idea is make a tree-wide
arch_get_securebooti.e. to move currentarch_ima_get_securebootcode to arch-specific secure boot implementation. By this way, there will no need for a newKconfigoptionINTEGRITY_SECURE_BOOT. But I'm not sure if there is any unforeseen concern.Originally basing IMA policy on the secure boot mode was an exception. As long as making it public isn't an issue any longer, this sounds to me. Ard, Dave, do you have any issues with replacing
arch_ima_get_secureboot()witharch_get_secureboot()?Quoted 2 lines
I don't see an issue with that. If there is a legitimate need to determine this even if IMA is not enabled, then this makes sense.
Ard, Dave -
Quoted 8 lines
FYI, Coiby posted v3 of this patch set[1], which is queued in the next- integrity-testing branch[2].
[1]
https://lore.kernel.org/linux-integrity/[email protected]/[2] https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git/
Ack. Looks fine to me.
Re: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
In reply to Mimi ZoharQuoted 10 lines · Mimi Zohar
As not all arch's implement
arch_integrity_get_secureboot, the definition ininclude/linux/integrity.hwould need to be updated. Something like:(quoted diff) +3
-1-#ifdef CONFIG_INTEGRITY_SECURE_BOOT +#if (defined(CONFIG_INTEGRITY_SECURE_BOOT) && \ + (defined(CONFIG_X86) && defined(CONFIG_EFI)) || defined(CONFIG_S390) \ + || defined(CONFIG_PPC_SECURE_BOOT))Then
IMA_SECURE_AND_OR_TRUSTED_BOOTand EVM could selectINTEGRITY_SECURE_BOOT, as suggested.
This seems to be going a wee bit sideways. :)
This kind of CONFIG complexity really should be left to Kconfig. C macros really aren't a great place to do it.
The other idiom we use a lot is this in generic code:
#ifndef arch_foo
static inline void arch_foo(void) {}
#endif
Then all you have to do is make sure the arch header that #defines it is included before the generic code. I'm not a super huge fan of these because it can be hard to tell (for humans at least) _if_ the architecture has done the #define.
But it sure beats that #ifdef maze.
Mimi Zohar
maintainerRe: [PATCH 1/3] integrity: Make arch_ima_get_secureboot integrity-wide
Hi Dave!
Quoted 9 lines · Dave Hansen
Quoted 8 lines · Mimi Zohar
As not all arch's implement
arch_integrity_get_secureboot, the definition ininclude/linux/integrity.hwould need to be updated. Something like:(quoted diff) +3
-1-#ifdef CONFIG_INTEGRITY_SECURE_BOOT +#if (defined(CONFIG_INTEGRITY_SECURE_BOOT) && \ + (defined(CONFIG_X86) && defined(CONFIG_EFI)) || defined(CONFIG_S390) \ + || defined(CONFIG_PPC_SECURE_BOOT))
Quoted 4 lines
Quoted 2 lines
Then
IMA_SECURE_AND_OR_TRUSTED_BOOTand EVM could selectINTEGRITY_SECURE_BOOT, as suggested.This seems to be going a wee bit sideways. :)
Agreed, that was my point. :) "imply" was cleaner, but Ard objected to two
imply's.
Quoted 10 lines
This kind of CONFIG complexity really should be left to
Kconfig. C macros really aren't a great place to do it.The other idiom we use a lot is this in generic code:
#ifndef
arch_foo
static inline voidarch_foo(void){}
#endif
Quoted 6 lines
Then all you have to do is make sure the arch header that #defines it is included before the generic code. I'm not a super huge fan of these because it can be hard to tell (for humans at least) _if_ the architecture has done the #define.
But it sure beats that #ifdef maze.
Sure.
PATCH 2/3 evm: Don't enable fix mode when secure boot is enabled
In reply to Coiby XuSimilar to IMA fix mode, forbid EVM fix mode when secure boot is enabled.
--- security/integrity/evm/evm_main.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
security/integrity/evm/evm_main.c +17 -7
@@ -72,17 +72,25 @@ static struct xattr_list evm_config_default_xattrnames[] = {LIST_HEAD (evm_config_xattrnames); +static char *evm_cmdline__initdata ; +core_param (evm, evm_cmdline, charp,0 ); +static int evm_fixmode__ro_after_init ; -static int __init evm_set_fixmode (char *str) +static void __init evm_set_fixmode (void ) { -if (strncmp (str,"fix" ,3 ) ==0 ) - evm_fixmode =1 ; -else -pr_err ("invalid \"%s\" mode" , str); +if (!evm_cmdline) +return ; -return 1 ; +if (strncmp (evm_cmdline,"fix" ,3 ) ==0 ) { +if (arch_integrity_get_secureboot ()) { +pr_info ("Secure boot enabled: ignoring evm=fix" ); +return ; + } + evm_fixmode =1 ; + }else { +pr_err ("invalid \"%s\" mode" , evm_cmdline); + } } -__setup ("evm=" , evm_set_fixmode);static void __init evm_init_config (void ) {
@@ -1119,6 +1127,8 @@ static int __init init_evm(void)evm_init_config (); +evm_set_fixmode (); + error =integrity_init_keyring (INTEGRITY_KEYRING_EVM );if (error) goto error;
Signature · 1 line
2.52.0
Re: [PATCH 2/3] evm: Don't enable fix mode when secure boot is enabled
Quoted 6 lines · Coiby Xu
Similar to IMA fix mode, forbid EVM fix mode when secure boot is enabled.
Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Signed-off-by Coiby Xu <[email protected]>
Thanks, Coiby!
Re: [PATCH 2/3] evm: Don't enable fix mode when secure boot is enabled
Quoted 6 lines · Mimi Zohar
Quoted 5 lines · Coiby Xu
Similar to IMA fix mode, forbid EVM fix mode when secure boot is enabled.
Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>
Ah, if possible, could you please change the email to [email protected]?
Thanks
Roberto
Quoted 5 lines
Quoted 1 line
Signed-off-by Coiby Xu <[email protected]>Thanks, Coiby!
Reviewed-by Mimi Zohar <[email protected]>
Re: [PATCH 2/3] evm: Don't enable fix mode when secure boot is enabled
Quoted 10 lines · Roberto Sassu
Quoted 6 lines · Mimi Zohar
Quoted 5 lines · Coiby Xu
Similar to IMA fix mode, forbid EVM fix mode when secure boot is enabled.
Reported-and-suggested-by Mimi Zohar <[email protected]>Suggested-by Roberto Sassu <[email protected]>Ah, if possible, could you please change the email to [email protected]?
Thanks for the reminder! I'll use the above email.
Signature · 2 lines
Best regards, Coiby
PATCH 3/3 s390: Drop unnecessary CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT
In reply to Coiby XuCommit b5ca117365d9 ("ima: prevent kexec_load syscall based on runtime secureboot flag") and commit 268a78404973 ("s390/kexec_file: Disable kexec_load when IPLed secure") disabled the kexec_load syscall based on the secureboot mode. Commit 9e2b4be377f0 ("ima: add a new CONFIG for loading arch-specific policies") needed to detect the secure boot mode, not to load an IMA architecture specific policy. Since there is the new CONFIG_INTEGRITY_SECURE_BOOT, drop CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT for s390.
--- arch/s390/Kconfig | 1 - arch/s390/kernel/Makefile | 1 - arch/s390/kernel/ima_arch.c | 8 -------- 3 files changed, 10 deletions(-) delete mode 100644 arch/s390/kernel/ima_arch.c
arch/s390/Kconfig +0 -1
@@ -77,7 +77,6 @@ config S390 # # Note: keep this list sorted alphabetically # - imply IMA_SECURE_AND_OR_TRUSTED_BOOT imply INTEGRITY_SECURE_BOOT select ALTERNATE_USER_ADDRESS_SPACE select ARCH_32BIT_USTAT_F_TINODE
arch/s390/kernel/Makefile +0 -1
@@ -71,7 +71,6 @@ obj-$(CONFIG_STACKPROTECTOR) += stackprotector.o obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o obj-$(CONFIG_CERT_STORE) += cert_store.o -obj-$(CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT) += ima_arch.o obj-$(CONFIG_INTEGRITY_SECURE_BOOT) += integrity_sb_arch.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o
arch/s390/kernel/ima_arch.c deleted +0 -8
@@ -1,8 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include <linux/ima.h> - -const char *const *arch_get_ima_policy (void ) -{ -return NULL ; -}
Signature · 1 line
2.52.0
Tested the entire patch series with s390 (with _and_ without secure boot), and everything seems to work as expected.