From: Matthew Garrett Date: Wed, 8 Nov 2017 15:11:32 +0000 (+0000) Subject: kexec: Disable at runtime if the kernel is locked down X-Git-Tag: archive/raspbian/4.18.10-2+rpi1^2~50 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=eb84ce0fd84767bee52acbe65b97cdb50fc1ad8c;p=linux.git kexec: Disable at runtime if the kernel is locked down kexec 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 in this situation. This does not affect kexec_file_load() which can check for a signature on the image to be booted. Signed-off-by: Matthew Garrett Signed-off-by: David Howells Acked-by: Dave Young Reviewed-by: "Lee, Chun-Yi" Reviewed-by: James Morris cc: kexec@lists.infradead.org Gbp-Pq: Topic features/all/lockdown Gbp-Pq: Name 0006-kexec-Disable-at-runtime-if-the-kernel-is-locked-dow.patch --- diff --git a/kernel/kexec.c b/kernel/kexec.c index aed8fb2564b..1553ac765e7 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -199,6 +199,13 @@ static inline int kexec_load_check(unsigned long nr_segments, if (!capable(CAP_SYS_BOOT) || kexec_load_disabled) return -EPERM; + /* + * kexec can be used to circumvent module loading restrictions, so + * prevent loading in that case + */ + if (kernel_is_locked_down("kexec of unsigned images")) + return -EPERM; + /* * Verify we have a legal set of flags * This leaves us room for future extensions.