summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorCoiby Xu <coxu@redhat.com>2022-07-13 15:21:11 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-07-21 21:20:11 +0200
commiteb360267e1e972475023d06546e18365a222698c (patch)
tree45d8fa5fdc0fe5473a15c8fc19128602495652c4 /kernel
parent29c6a632f8193b0a4b40156afb823371d1d4c05a (diff)
downloadlinux-stable-eb360267e1e972475023d06546e18365a222698c.tar.gz
linux-stable-eb360267e1e972475023d06546e18365a222698c.tar.bz2
linux-stable-eb360267e1e972475023d06546e18365a222698c.zip
ima: force signature verification when CONFIG_KEXEC_SIG is configured
[ Upstream commit af16df54b89dee72df253abc5e7b5e8a6d16c11c ] Currently, an unsigned kernel could be kexec'ed when IMA arch specific policy is configured unless lockdown is enabled. Enforce kernel signature verification check in the kexec_file_load syscall when IMA arch specific policy is configured. Fixes: 99d5cadfde2b ("kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE") Reported-and-suggested-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Coiby Xu <coxu@redhat.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kexec_file.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 2e0f0b3fb9ab..fff11916aba3 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -29,6 +29,15 @@
#include <linux/vmalloc.h>
#include "kexec_internal.h"
+#ifdef CONFIG_KEXEC_SIG
+static bool sig_enforce = IS_ENABLED(CONFIG_KEXEC_SIG_FORCE);
+
+void set_kexec_sig_enforced(void)
+{
+ sig_enforce = true;
+}
+#endif
+
static int kexec_calculate_store_digests(struct kimage *image);
/*
@@ -159,7 +168,7 @@ kimage_validate_signature(struct kimage *image)
image->kernel_buf_len);
if (ret) {
- if (IS_ENABLED(CONFIG_KEXEC_SIG_FORCE)) {
+ if (sig_enforce) {
pr_notice("Enforced kernel signature verification failed (%d).\n", ret);
return ret;
}