[PATCH v2 1/3] kexec_file: update IMA after machine post-load
Jérémy Jean
Jeremy.Jean at oss.cyber.gouv.fr
Thu Nov 12 04:52:45 PST 2026
ima_kexec_post_load() replaces the global IMA mapping with a mapping for
the new image. If machine_kexec_post_load() fails, the new image is
freed but that mapping remains. The installed image no longer receives
the execute-time IMA update, and the notifier can write the
measurement list into freed pages.
Call the machine hook first. Return its error before updating IMA so IMA
changes the mapping only for an image which will be installed.
Fixes: 9f0ec4b16f2b ("ima: kexec: move IMA log copy from kexec load to execute")
Cc: stable at vger.kernel.org
Signed-off-by: Jérémy Jean <Jeremy.Jean at oss.cyber.gouv.fr>
---
kernel/kexec_file.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index b668ce8d68ee..59f9ba1b0cd7 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -206,11 +206,17 @@ kimage_validate_signature(struct kimage *image)
static int kexec_post_load(struct kimage *image, unsigned long flags)
{
+ int ret;
+
+ ret = machine_kexec_post_load(image);
+ if (ret)
+ return ret;
+
#ifdef CONFIG_IMA_KEXEC
if (!(flags & KEXEC_FILE_ON_CRASH))
ima_kexec_post_load(image);
#endif
- return machine_kexec_post_load(image);
+ return 0;
}
/*
More information about the kexec
mailing list