Commit 7d31f460 authored by Matthew Garrett's avatar Matthew Garrett Committed by James Morris
Browse files

kexec_load: Disable at runtime if the kernel is locked down



The kexec_load() syscall permits the loading and execution of arbitrary
code in ring 0, which is something that lock-down is meant to prevent. It
makes sense to disable kexec_load() in this situation.

This does not affect kexec_file_load() syscall which can check for a
signature on the image to be booted.

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarMatthew Garrett <mjg59@google.com>
Acked-by: default avatarDave Young <dyoung@redhat.com>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
cc: kexec@lists.infradead.org
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 9b9d8dda
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ enum lockdown_reason {
	LOCKDOWN_NONE,
	LOCKDOWN_MODULE_SIGNATURE,
	LOCKDOWN_DEV_MEM,
	LOCKDOWN_KEXEC,
	LOCKDOWN_INTEGRITY_MAX,
	LOCKDOWN_CONFIDENTIALITY_MAX,
};
+8 −0
Original line number Diff line number Diff line
@@ -205,6 +205,14 @@ static inline int kexec_load_check(unsigned long nr_segments,
	if (result < 0)
		return result;

	/*
	 * kexec can be used to circumvent module loading restrictions, so
	 * prevent loading in that case
	 */
	result = security_locked_down(LOCKDOWN_KEXEC);
	if (result)
		return result;

	/*
	 * Verify we have a legal set of flags
	 * This leaves us room for future extensions.
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = {
	[LOCKDOWN_NONE] = "none",
	[LOCKDOWN_MODULE_SIGNATURE] = "unsigned module loading",
	[LOCKDOWN_DEV_MEM] = "/dev/mem,kmem,port",
	[LOCKDOWN_KEXEC] = "kexec of unsigned images",
	[LOCKDOWN_INTEGRITY_MAX] = "integrity",
	[LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality",
};