History

arm64: Unconditionally enable PAN support

FEAT_PAN has been around since ARMv8.1 (over 11 years ago), has no compiler dependency (we have our own accessors), and is a great security benefit. Drop CONFIG_ARM64_PAN, and make the support unconditionnal.

Marc Zyngier committed 10 months ago

Commit 018a2311 parent 6191b255 files · +3 −28Browse files

Unified · Split

5 files
  1. arch/arm64/Kconfig +0 −17
  2. arch/arm64/include/asm/cpucaps.h +0 −2
  3. arch/arm64/include/asm/uaccess.h +2 −4
  4. arch/arm64/kernel/cpufeature.c +0 −4
  5. arch/arm64/kvm/hyp/entry.S +1 −1
arch/arm64/Kconfig+0−17
@@ -1680,7 +1680,6 @@ config MITIGATE_SPECTRE_BRANCH_HISTORY · 1679 unmodified lines
16801680 config ARM64_SW_TTBR0_PAN
16811681 bool "Emulate Privileged Access Never using TTBR0_EL1 switching"
16821682 depends on !KCSAN
1683− select ARM64_PAN
16841683 help
16851684 Enabling this option prevents the kernel from accessing
16861685 user-space memory directly by pointing TTBR0_EL1 to a reserved
@@ -1859,20 +1858,6 @@ config ARM64_HW_AFDBM · 172 unmodified lines
18591858 to work on pre-ARMv8.1 hardware and the performance impact is
18601859 minimal. If unsure, say Y.
18611860
1862−config ARM64_PAN
1863− bool "Enable support for Privileged Access Never (PAN)"
1864− default y
1865− help
1866− Privileged Access Never (PAN; part of the ARMv8.1 Extensions)
1867− prevents the kernel or hypervisor from accessing user-space (EL0)
1868− memory directly.
1869−
1870− Choosing this option will cause any unprotected (not using
1871− copy_to_user et al) memory access to fail with a permission fault.
1872−
1873− The feature is detected at runtime, and will remain as a 'nop'
1874− instruction if the cpu does not implement the feature.
1875−
18761861 endmenu # "ARMv8.1 architectural features"
18771862
18781863 menu "ARMv8.2 architectural features"
@@ -2109,7 +2094,6 @@ config ARM64_MTE · 230 unmodified lines
21092094 depends on ARM64_AS_HAS_MTE && ARM64_TAGGED_ADDR_ABI
21102095 depends on AS_HAS_ARMV8_5
21112096 # Required for tag checking in the uaccess routines
2112− select ARM64_PAN
21132097 select ARCH_HAS_SUBPAGE_FAULTS
21142098 select ARCH_USES_HIGH_VMA_FLAGS
21152099 select ARCH_USES_PG_ARCH_2
@@ -2141,7 +2125,6 @@ menu "ARMv8.7 architectural features" · 25 unmodified lines
21412125 config ARM64_EPAN
21422126 bool "Enable support for Enhanced Privileged Access Never (EPAN)"
21432127 default y
2144− depends on ARM64_PAN
21452128 help
21462129 Enhanced Privileged Access Never (EPAN) allows Privileged
21472130 Access Never to be used with Execute-only mappings.
arch/arm64/include/asm/cpucaps.h+0−2
@@ -19,8 +19,6 @@ cpucap_is_possible(const unsigned int cap) · 18 unmodified lines
1919 "cap must be < ARM64_NCAPS");
2020
2121 switch (cap) {
22− case ARM64_HAS_PAN:
23− return IS_ENABLED(CONFIG_ARM64_PAN);
2422 case ARM64_HAS_EPAN:
2523 return IS_ENABLED(CONFIG_ARM64_EPAN);
2624 case ARM64_SVE:
arch/arm64/include/asm/uaccess.h+2−4
@@ -124,14 +124,12 @@ static inline bool uaccess_ttbr0_enable(void) · 123 unmodified lines
124124
125125 static inline void __uaccess_disable_hw_pan(void)
126126 {
127− asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN,
128− CONFIG_ARM64_PAN));
127+ asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN));
129128 }
130129
131130 static inline void __uaccess_enable_hw_pan(void)
132131 {
133− asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
134− CONFIG_ARM64_PAN));
132+ asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN));
135133 }
136134
137135 static inline void uaccess_disable_privileged(void)
arch/arm64/kernel/cpufeature.c+0−4
@@ -2164,7 +2164,6 @@ static bool has_bbml2_noabort(const struct arm64_cpu_capabilities *caps, int sco · 2163 unmodified lines
21642164 return cpu_supports_bbml2_noabort();
21652165 }
21662166
2167−#ifdef CONFIG_ARM64_PAN
21682167 static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused)
21692168 {
21702169 /*
@@ -2176,7 +2175,6 @@ static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused) · 5 unmodified lines
21762175 sysreg_clear_set(sctlr_el1, SCTLR_EL1_SPAN, 0);
21772176 set_pstate_pan(1);
21782177 }
2179−#endif /* CONFIG_ARM64_PAN */
21802178
21812179 #ifdef CONFIG_ARM64_RAS_EXTN
21822180 static void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused)
@@ -2541,7 +2539,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = { · 358 unmodified lines
25412539 .matches = has_cpuid_feature,
25422540 ARM64_CPUID_FIELDS(ID_AA64MMFR0_EL1, ECV, CNTPOFF)
25432541 },
2544−#ifdef CONFIG_ARM64_PAN
25452542 {
25462543 .desc = "Privileged Access Never",
25472544 .capability = ARM64_HAS_PAN,
@@ -2550,7 +2547,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = { · 2 unmodified lines
25502547 .cpu_enable = cpu_enable_pan,
25512548 ARM64_CPUID_FIELDS(ID_AA64MMFR1_EL1, PAN, IMP)
25522549 },
2553−#endif /* CONFIG_ARM64_PAN */
25542550 #ifdef CONFIG_ARM64_EPAN
25552551 {
25562552 .desc = "Enhanced Privileged Access Never",
arch/arm64/kvm/hyp/entry.S+1−1
@@ -126,7 +126,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL) · 125 unmodified lines
126126
127127 add x1, x1, #VCPU_CONTEXT
128128
129− ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN)
129+ ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN)
130130
131131 // Store the guest regs x2 and x3
132132 stp x2, x3, [x1, #CPU_XREG_OFFSET(2)]

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t