Skip to content

Commit

Permalink
powerpc/32s: Allow disabling KUEP at boot time
Browse files Browse the repository at this point in the history
PPC64 uses MMU features to enable/disable KUEP at boot time.
But feature fixups are applied way too early on PPC32.

Now that all KUEP related actions are in C following the
conversion of KUEP initial setup and context switch in C,
static branches can be used to enable/disable KUEP.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/7745a2c3a08ec46302920a3f48d1cb9b5469dbbb.1622708530.git.christophe.leroy@csgroup.eu
  • Loading branch information
Christophe Leroy authored and Michael Ellerman committed Jun 16, 2021
1 parent 86f46f3 commit 50d2f10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion arch/powerpc/include/asm/book3s/32/kup.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

#ifndef __ASSEMBLY__

#include <linux/jump_label.h>

extern struct static_key_false disable_kuep_key;

static __always_inline bool kuap_is_disabled(void)
{
return !IS_ENABLED(CONFIG_PPC_KUAP);
}

static __always_inline bool kuep_is_disabled(void)
{
return !IS_ENABLED(CONFIG_PPC_KUEP);
return !IS_ENABLED(CONFIG_PPC_KUEP) || static_branch_unlikely(&disable_kuep_key);
}

static inline void kuep_lock(void)
Expand Down
11 changes: 7 additions & 4 deletions arch/powerpc/mm/book3s32/kuep.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
#include <asm/kup.h>
#include <asm/smp.h>

struct static_key_false disable_kuep_key;

void __init setup_kuep(bool disabled)
{
kuep_lock();
if (!disabled)
kuep_lock();

if (smp_processor_id() != boot_cpuid)
return;

pr_info("Activating Kernel Userspace Execution Prevention\n");

if (disabled)
pr_warn("KUEP cannot be disabled yet on 6xx when compiled in\n");
static_branch_enable(&disable_kuep_key);
else
pr_info("Activating Kernel Userspace Execution Prevention\n");
}

0 comments on commit 50d2f10

Please sign in to comment.