Christophe Leroy | b5efec0 | 2021-03-12 12:50:47 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | |
| 3 | #include <asm/kup.h> |
Christophe Leroy | 86f46f3 | 2021-06-03 08:41:41 +0000 | [diff] [blame] | 4 | #include <asm/smp.h> |
Christophe Leroy | 91ec667 | 2021-06-03 08:41:36 +0000 | [diff] [blame] | 5 | |
Christophe Leroy | 50d2f10 | 2021-06-03 08:41:42 +0000 | [diff] [blame] | 6 | struct static_key_false disable_kuep_key; |
| 7 | |
Christophe Leroy | c89e632 | 2021-06-28 06:56:11 +0000 | [diff] [blame] | 8 | void setup_kuep(bool disabled) |
Christophe Leroy | 91ec667 | 2021-06-03 08:41:36 +0000 | [diff] [blame] | 9 | { |
Christophe Leroy | 50d2f10 | 2021-06-03 08:41:42 +0000 | [diff] [blame] | 10 | if (!disabled) |
| 11 | kuep_lock(); |
Christophe Leroy | 86f46f3 | 2021-06-03 08:41:41 +0000 | [diff] [blame] | 12 | |
| 13 | if (smp_processor_id() != boot_cpuid) |
| 14 | return; |
| 15 | |
Christophe Leroy | 91ec667 | 2021-06-03 08:41:36 +0000 | [diff] [blame] | 16 | if (disabled) |
Christophe Leroy | 50d2f10 | 2021-06-03 08:41:42 +0000 | [diff] [blame] | 17 | static_branch_enable(&disable_kuep_key); |
| 18 | else |
| 19 | pr_info("Activating Kernel Userspace Execution Prevention\n"); |
Christophe Leroy | 91ec667 | 2021-06-03 08:41:36 +0000 | [diff] [blame] | 20 | } |