kexec_file: Restrict at runtime if the kernel is locked down
authorJiri Bohac <jbohac@suse.cz>
Tue, 20 Aug 2019 00:17:45 +0000 (17:17 -0700)
committerJames Morris <jmorris@namei.org>
Tue, 20 Aug 2019 04:54:15 +0000 (21:54 -0700)
When KEXEC_SIG is not enabled, kernel should not load images through
kexec_file systemcall if the kernel is locked down.

[Modified by David Howells to fit with modifications to the previous patch
 and to return -EPERM if the kernel is locked down for consistency with
 other lockdowns. Modified by Matthew Garrett to remove the IMA
 integration, which will be replaced by integrating with the IMA
 architecture policy patches.]

Signed-off-by: Jiri Bohac <jbohac@suse.cz>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Matthew Garrett <mjg59@google.com>
cc: kexec@lists.infradead.org
Signed-off-by: James Morris <jmorris@namei.org>
kernel/kexec_file.c

index 972931201995f8b71b42ec75eb76581e253fd20d..43109ef4d6bf3686dfe6ba1a6a4dfe9f93fb0e38 100644 (file)
@@ -208,7 +208,7 @@ kimage_validate_signature(struct kimage *image)
                        return ret;
                }
 
-               return 0;
+               return security_locked_down(LOCKDOWN_KEXEC);
 
                /* All other errors are fatal, including nomem, unparseable
                 * signatures and signature check failures - even if signatures