Skip to content

Commit 7d31f46

Browse files
mjg59xjamesmorris
authored andcommitted
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: David Howells <dhowells@redhat.com> Signed-off-by: Matthew Garrett <mjg59@google.com> Acked-by: Dave Young <dyoung@redhat.com> Reviewed-by: Kees Cook <keescook@chromium.org> cc: kexec@lists.infradead.org Signed-off-by: James Morris <jmorris@namei.org>
1 parent 9b9d8dd commit 7d31f46

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎include/linux/security.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ enum lockdown_reason {
105105
LOCKDOWN_NONE,
106106
LOCKDOWN_MODULE_SIGNATURE,
107107
LOCKDOWN_DEV_MEM,
108+
LOCKDOWN_KEXEC,
108109
LOCKDOWN_INTEGRITY_MAX,
109110
LOCKDOWN_CONFIDENTIALITY_MAX,
110111
};

‎kernel/kexec.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ static inline int kexec_load_check(unsigned long nr_segments,
205205
if (result < 0)
206206
return result;
207207

208+
/*
209+
* kexec can be used to circumvent module loading restrictions, so
210+
* prevent loading in that case
211+
*/
212+
result = security_locked_down(LOCKDOWN_KEXEC);
213+
if (result)
214+
return result;
215+
208216
/*
209217
* Verify we have a legal set of flags
210218
* This leaves us room for future extensions.

‎security/lockdown/lockdown.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = {
2020
[LOCKDOWN_NONE] = "none",
2121
[LOCKDOWN_MODULE_SIGNATURE] = "unsigned module loading",
2222
[LOCKDOWN_DEV_MEM] = "/dev/mem,kmem,port",
23+
[LOCKDOWN_KEXEC] = "kexec of unsigned images",
2324
[LOCKDOWN_INTEGRITY_MAX] = "integrity",
2425
[LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality",
2526
};

0 commit comments

Comments
 (0)