diff options
author | Nayna Jain <nayna@linux.ibm.com> | 2018-10-09 13:30:34 -0400 |
---|---|---|
committer | Mimi Zohar <zohar@linux.ibm.com> | 2018-12-11 07:10:33 -0500 |
commit | b5ca117365d960fe5e4fe272bcc8142c28769383 (patch) | |
tree | 6e306a5c52ad13271a2d947c9a41922f1ddf709d /security | |
parent | 0914ade209c452cff6a29b1c0ae6fff3167fa1d0 (diff) |
ima: prevent kexec_load syscall based on runtime secureboot flag
When CONFIG_KEXEC_VERIFY_SIG is enabled, the kexec_file_load syscall
requires the kexec'd kernel image to be signed. Distros are concerned
about totally disabling the kexec_load syscall. As a compromise, the
kexec_load syscall will only be disabled when CONFIG_KEXEC_VERIFY_SIG
is configured and the system is booted with secureboot enabled.
This patch disables the kexec_load syscall only for systems booted with
secureboot enabled.
[zohar@linux.ibm.com: add missing mesage on kexec_load failure]
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Peter Jones <pjones@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/integrity/ima/ima_main.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 1b88d58e1325..df0b2ee49fa2 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c | |||
@@ -505,20 +505,26 @@ int ima_post_read_file(struct file *file, void *buf, loff_t size, | |||
505 | */ | 505 | */ |
506 | int ima_load_data(enum kernel_load_data_id id) | 506 | int ima_load_data(enum kernel_load_data_id id) |
507 | { | 507 | { |
508 | bool sig_enforce; | 508 | bool ima_enforce, sig_enforce; |
509 | 509 | ||
510 | if ((ima_appraise & IMA_APPRAISE_ENFORCE) != IMA_APPRAISE_ENFORCE) | 510 | ima_enforce = |
511 | return 0; | 511 | (ima_appraise & IMA_APPRAISE_ENFORCE) == IMA_APPRAISE_ENFORCE; |
512 | 512 | ||
513 | switch (id) { | 513 | switch (id) { |
514 | case LOADING_KEXEC_IMAGE: | 514 | case LOADING_KEXEC_IMAGE: |
515 | if (ima_appraise & IMA_APPRAISE_KEXEC) { | 515 | if (IS_ENABLED(CONFIG_KEXEC_VERIFY_SIG) |
516 | && arch_ima_get_secureboot()) { | ||
517 | pr_err("impossible to appraise a kernel image without a file descriptor; try using kexec_file_load syscall.\n"); | ||
518 | return -EACCES; | ||
519 | } | ||
520 | |||
521 | if (ima_enforce && (ima_appraise & IMA_APPRAISE_KEXEC)) { | ||
516 | pr_err("impossible to appraise a kernel image without a file descriptor; try using kexec_file_load syscall.\n"); | 522 | pr_err("impossible to appraise a kernel image without a file descriptor; try using kexec_file_load syscall.\n"); |
517 | return -EACCES; /* INTEGRITY_UNKNOWN */ | 523 | return -EACCES; /* INTEGRITY_UNKNOWN */ |
518 | } | 524 | } |
519 | break; | 525 | break; |
520 | case LOADING_FIRMWARE: | 526 | case LOADING_FIRMWARE: |
521 | if (ima_appraise & IMA_APPRAISE_FIRMWARE) { | 527 | if (ima_enforce && (ima_appraise & IMA_APPRAISE_FIRMWARE)) { |
522 | pr_err("Prevent firmware sysfs fallback loading.\n"); | 528 | pr_err("Prevent firmware sysfs fallback loading.\n"); |
523 | return -EACCES; /* INTEGRITY_UNKNOWN */ | 529 | return -EACCES; /* INTEGRITY_UNKNOWN */ |
524 | } | 530 | } |
@@ -526,7 +532,8 @@ int ima_load_data(enum kernel_load_data_id id) | |||
526 | case LOADING_MODULE: | 532 | case LOADING_MODULE: |
527 | sig_enforce = is_module_sig_enforced(); | 533 | sig_enforce = is_module_sig_enforced(); |
528 | 534 | ||
529 | if (!sig_enforce && (ima_appraise & IMA_APPRAISE_MODULES)) { | 535 | if (ima_enforce && (!sig_enforce |
536 | && (ima_appraise & IMA_APPRAISE_MODULES))) { | ||
530 | pr_err("impossible to appraise a module without a file descriptor. sig_enforce kernel parameter might help\n"); | 537 | pr_err("impossible to appraise a module without a file descriptor. sig_enforce kernel parameter might help\n"); |
531 | return -EACCES; /* INTEGRITY_UNKNOWN */ | 538 | return -EACCES; /* INTEGRITY_UNKNOWN */ |
532 | } | 539 | } |