From: Matthew Garrett Date: Wed, 5 Apr 2017 16:40:30 +0000 (+0100) Subject: kexec: Disable at runtime if the kernel is locked down X-Git-Tag: archive/raspbian/4.15.4-1+rpi1~1^2^2~65 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b9ea179804b590603f2a4ad2cdb5fba99eded331;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 Gbp-Pq: Topic features/all/lockdown Gbp-Pq: Name 0044-kexec-Disable-at-runtime-if-the-kernel-is-locked-dow.patch --- diff --git a/kernel/kexec.c b/kernel/kexec.c index e62ec4dc662..37f75d0b75d 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -201,6 +201,13 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, 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()) + return -EPERM; + /* * Verify we have a legal set of flags * This leaves us room for future extensions.