Skip to content

Commit af16df5

Browse files
coibymimizohar
authored andcommitted
ima: force signature verification when CONFIG_KEXEC_SIG is configured
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: 99d5cad ("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>
1 parent d2ee2cf commit af16df5

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

include/linux/kexec.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ static inline int kexec_crash_loaded(void) { return 0; }
452452
#define kexec_in_progress false
453453
#endif /* CONFIG_KEXEC_CORE */
454454

455+
#ifdef CONFIG_KEXEC_SIG
456+
void set_kexec_sig_enforced(void);
457+
#else
458+
static inline void set_kexec_sig_enforced(void) {}
459+
#endif
460+
455461
#endif /* !defined(__ASSEBMLY__) */
456462

457463
#endif /* LINUX_KEXEC_H */

kernel/kexec_file.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
#include <linux/vmalloc.h>
3030
#include "kexec_internal.h"
3131

32+
#ifdef CONFIG_KEXEC_SIG
33+
static bool sig_enforce = IS_ENABLED(CONFIG_KEXEC_SIG_FORCE);
34+
35+
void set_kexec_sig_enforced(void)
36+
{
37+
sig_enforce = true;
38+
}
39+
#endif
40+
3241
static int kexec_calculate_store_digests(struct kimage *image);
3342

3443
/*
@@ -159,7 +168,7 @@ kimage_validate_signature(struct kimage *image)
159168
image->kernel_buf_len);
160169
if (ret) {
161170

162-
if (IS_ENABLED(CONFIG_KEXEC_SIG_FORCE)) {
171+
if (sig_enforce) {
163172
pr_notice("Enforced kernel signature verification failed (%d).\n", ret);
164173
return ret;
165174
}

security/integrity/ima/ima_efi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ const char * const *arch_get_ima_policy(void)
6767
if (IS_ENABLED(CONFIG_IMA_ARCH_POLICY) && arch_ima_get_secureboot()) {
6868
if (IS_ENABLED(CONFIG_MODULE_SIG))
6969
set_module_sig_enforced();
70+
if (IS_ENABLED(CONFIG_KEXEC_SIG))
71+
set_kexec_sig_enforced();
7072
return sb_arch_rules;
7173
}
7274
return NULL;

0 commit comments

Comments
 (0)