Skip to content

Commit

Permalink
kexec: Disable at runtime if securelevel has been set.
Browse files Browse the repository at this point in the history
kexec permits the loading and execution of arbitrary code in ring 0, which
permits the modification of the running kernel. Prevent this if securelevel
has been set.

Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
  • Loading branch information
mjg59 authored and Matthew Garrett committed Apr 3, 2016
1 parent 9524fad commit ec87b6a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/kexec.c
Expand Up @@ -17,6 +17,7 @@
#include <linux/syscalls.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/security.h>

#include "kexec_internal.h"

Expand Down Expand Up @@ -134,6 +135,9 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
if (!capable(CAP_SYS_BOOT) || kexec_load_disabled)
return -EPERM;

if (get_securelevel() > 0)
return -EPERM;

/*
* Verify we have a legal set of flags
* This leaves us room for future extensions.
Expand Down

0 comments on commit ec87b6a

Please sign in to comment.