Add support for arm64 to carry ima measurement log in kexec_file_load
cover Add support for arm64 to carry ima measurement log in kexec_file_load
Add support for arm64 to carry ima measurement log to the next kexec'ed session triggered via kexec_file_load.
- Top of Linux 5.3-rc6
Currently during kexec the kernel file signatures are/can be validated prior to actual load, the information(PE/ima signature) is not carried to the next session. This lead to loss of information.
Carrying forward the ima measurement log to the next kexec'ed session. This allows a verifying party to get the entire runtime event log since the last full reboot since that is when PCRs were last reset.
Prakhar Srivastava (1):
Add support for arm64 to carry ima measurement log in kexec_file_load
arch/arm64/Kconfig | 7 + arch/arm64/include/asm/ima.h | 29 ++++ arch/arm64/include/asm/kexec.h | 5 + arch/arm64/kernel/Makefile | 3 +- arch/arm64/kernel/ima_kexec.c | 213 +++++++++++++++++++++++++ arch/arm64/kernel/machine_kexec_file.c | 6 + 6 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/ima.h create mode 100644 arch/arm64/kernel/ima_kexec.c
Signature · 1 line
2.17.1
RFC PATCH 1/1 Add support for arm64 to carry ima measurement log in kexec_file_load
During kexec_file_load, carrying forward the ima measurement log allows a verifying party to get the entire runtime event log since the last full reboot since that is when PCRs were last reset.
--- arch/arm64/Kconfig | 7 + arch/arm64/include/asm/ima.h | 29 ++++ arch/arm64/include/asm/kexec.h | 5 + arch/arm64/kernel/Makefile | 3 +- arch/arm64/kernel/ima_kexec.c | 213 +++++++++++++++++++++++++ arch/arm64/kernel/machine_kexec_file.c | 6 + 6 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/ima.h create mode 100644 arch/arm64/kernel/ima_kexec.c
arch/arm64/Kconfig +7 -0
@@ -976,6 +976,13 @@ config KEXEC_VERIFY_SIG verification for the corresponding kernel image type being loaded in order for this to work. +config HAVE_IMA_KEXEC + bool "Carry over IMA measurement log during kexec_file_load() syscall" + depends on KEXEC_FILE + help + Select this option to carry over IMA measurement log during + kexec_file_load. + config KEXEC_IMAGE_VERIFY_SIG bool "Enable Image signature verification support" default y
arch/arm64/include/asm/ima.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_ARM64_IMA_H +#define _ASM_ARM64_IMA_H + +struct kimage ; + +int ima_get_kexec_buffer (void **addr,size_t *size); +int ima_free_kexec_buffer (void ); + +#ifdef CONFIG_IMA +void remove_ima_buffer (void *fdt,int chosen_node); +#else +static inline void remove_ima_buffer (void *fdt,int chosen_node) {} +#endif + +#ifdef CONFIG_IMA_KEXEC +int arch_ima_add_kexec_buffer (struct kimage *image,unsigned long load_addr, +size_t size); + +int setup_ima_buffer (const struct kimage *image,void *fdt,int chosen_node); +#else +static inline int setup_ima_buffer (const struct kimage *image,void *fdt, +int chosen_node) +{ +remove_ima_buffer (fdt, chosen_node); +return 0 ; +} +#endif /* CONFIG_IMA_KEXEC */ +#endif /* _ASM_ARM64_IMA_H */
arch/arm64/include/asm/kexec.h +5 -0
@@ -96,6 +96,11 @@ static inline void crash_post_resume(void) {}struct kimage_arch {void *dtb;unsigned long dtb_mem; + +#ifdef CONFIG_IMA_KEXEC +phys_addr_t ima_buffer_addr; +size_t ima_buffer_size; +#endif };extern const struct kexec_file_ops kexec_image_ops;
arch/arm64/kernel/Makefile +2 -1
@@ -55,7 +55,8 @@ obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate-asm.o obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o \ cpu-reset.o -obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o +obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o \ + ima_kexec.o obj-$(CONFIG_ARM64_RELOC_TEST) += arm64-reloc-test.o arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
arch/arm64/kernel/ima_kexec.c new file +213 -0
213 lines not on this page · raw message
arch/arm64/kernel/machine_kexec_file.c +6 -0
@@ -21,6 +21,7 @@#include <linux/types.h> #include <linux/vmalloc.h> #include <asm/byteorder.h> +#include <asm/ima.h> /* relevant device tree properties */ #define FDT_PROP_INITRD_START "linux,initrd-start"
@@ -85,6 +86,11 @@ static int setup_dtb(struct kimage *image, goto out; } +/* add ima measuremnet log buffer */ + ret =setup_ima_buffer (image, dtb, off); +if (ret) + goto out; +/* add kaslr-seed */ ret =fdt_delprop (dtb, off,FDT_PROP_KASLR_SEED );if (ret == -FDT_ERR_NOTFOUND )
Signature · 1 line
2.17.1
Quoting Prakhar Srivastava (2019-09-06 16:51:09)
Quoted 8 lines
Add support for arm64 to carry ima measurement log to the next kexec'ed session triggered via
kexec_file_load.
- Top of Linux 5.3-rc6Currently during kexec the kernel file signatures are/can be validated prior to actual load, the information(PE/ima signature) is not carried to the next session. This lead to loss of information.
Quoted 6 lines
Carrying forward the ima measurement log to the next kexec'ed session. This allows a verifying party to get the entire runtime event log since the last full reboot since that is when PCRs were last reset.
Prakhar Srivastava (1):
Add support for arm64 to carry ima measurement log inkexec_file_load
Did anything change from the last round? Please include changelogs so we know what to look for.