Skip to contentSkip to conversation

arm64: bti: Fix support for userspace only BTI

PATCH Applied Mark Brown 2 participants 3 messages May 12, 2020 arm64

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH v2 1/1 arm64: bti: Fix support for userspace only BTI

When setting PTE_MAYBE_GP we check system_supports_bti() but this is true for systems where only CONFIG_BTI is set causing us to enable BTI on some kernel text. Add an extra check for the kernel mode option, using an ifdef due to line length.

Fixes c8027285e366 (arm64: Set GP bit in kernel page tables to enable BTI for the kernel)
---
 arch/arm64/include/asm/pgtable-prot.h | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm64/include/asm/pgtable-prot.h +8 -0
index 310690332896..2e7e0f452301 100644
@@ -32,7 +32,15 @@ extern bool arm64_use_ng_mappings;
 #define PTE_MAYBE_NG		(arm64_use_ng_mappings ? PTE_NG : 0)
 #define PMD_MAYBE_NG		(arm64_use_ng_mappings ? PMD_SECT_NG : 0)
 
+/*
+ * If we have userspace only BTI we don't want to mark kernel pages
+ * guarded even if the system does support BTI.
+ */
+#ifdef CONFIG_ARM64_BTI_KERNEL
 #define PTE_MAYBE_GP		(system_supports_bti() ? PTE_GP : 0)
+#else
+#define PTE_MAYBE_GP		0
+#endif
 
 #define PROT_DEFAULT		(_PROT_DEFAULT | PTE_MAYBE_NG)
 #define PROT_SECT_DEFAULT	(_PROT_SECT_DEFAULT | PMD_MAYBE_NG)
Signature · 7 lines
2.20.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Applied
#1 lore raw
Quoted 4 lines · Mark Brown

When setting PTE_MAYBE_GP we check system_supports_bti() but this is true for systems where only CONFIG_BTI is set causing us to enable BTI on some kernel text. Add an extra check for the kernel mode option, using an ifdef due to line length.

Applied to arm64 (for-next/bti), thanks!

[1/1] arm64: bti: Fix support for userspace only BTI

      https://git.kernel.org/arm64/c/e70b3b544798

Cheers,

Signature · 10 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#2 lore raw
Quoted 10 lines · Will Deacon
Quoted 4 lines · Mark Brown

When setting PTE_MAYBE_GP we check system_supports_bti() but this is true for systems where only CONFIG_BTI is set causing us to enable BTI on some kernel text. Add an extra check for the kernel mode option, using an ifdef due to line length.

Applied to arm64 (for-next/bti), thanks!

[1/1] arm64: bti: Fix support for userspace only BTI

      https://git.kernel.org/arm64/c/e70b3b544798

Damn, I just realised the 'Fixes:' tag is missing double-quotes around the subject. I'll fix that up now to avoid linux-next shouting at me, but it means the link above won't work any more because the SHA will change.

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel