2021-07-12 19:01:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include <asm/kup.h>
|
2021-07-20 16:20:39 +00:00
|
|
|
#include <asm/smp.h>
|
2021-07-12 19:01:19 +00:00
|
|
|
|
2021-07-20 16:20:39 +00:00
|
|
|
struct static_key_false disable_kuep_key;
|
2021-07-12 19:01:19 +00:00
|
|
|
|
2021-07-20 16:20:39 +00:00
|
|
|
void setup_kuep(bool disabled)
|
2021-07-12 19:01:19 +00:00
|
|
|
{
|
2021-07-20 16:20:39 +00:00
|
|
|
if (!disabled)
|
|
|
|
kuep_lock();
|
2021-07-12 19:01:19 +00:00
|
|
|
|
2021-07-20 16:20:39 +00:00
|
|
|
if (smp_processor_id() != boot_cpuid)
|
|
|
|
return;
|
2021-07-12 19:01:19 +00:00
|
|
|
|
2021-07-20 16:20:39 +00:00
|
|
|
if (disabled)
|
|
|
|
static_branch_enable(&disable_kuep_key);
|
|
|
|
else
|
|
|
|
pr_info("Activating Kernel Userspace Execution Prevention\n");
|
2021-07-12 19:01:19 +00:00
|
|
|
}
|