1From f7b3134457e764badb5b24d6fcd1636d1950b1ef Mon Sep 17 00:00:00 2001 2From: Catalin Marinas <catalin.marinas@arm.com> 3Date: Tue, 23 Jul 2019 19:58:39 +0200 4Subject: [PATCH] BACKPORT: arm64: Introduce prctl() options to control the 5 tagged user addresses ABI 6 7(Upstream commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d). 8 9It is not desirable to relax the ABI to allow tagged user addresses into 10the kernel indiscriminately. This patch introduces a prctl() interface 11for enabling or disabling the tagged ABI with a global sysctl control 12for preventing applications from enabling the relaxed ABI (meant for 13testing user-space prctl() return error checking without reconfiguring 14the kernel). The ABI properties are inherited by threads of the same 15application and fork()'ed children but cleared on execve(). A Kconfig 16option allows the overall disabling of the relaxed ABI. 17 18The PR_SET_TAGGED_ADDR_CTRL will be expanded in the future to handle 19MTE-specific settings like imprecise vs precise exceptions. 20 21Reviewed-by: Kees Cook <keescook@chromium.org> 22Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> 23Signed-off-by: Andrey Konovalov <andreyknvl@google.com> 24Signed-off-by: Will Deacon <will@kernel.org> 25Change-Id: I2d52c5589b05415faab315c116245f1058d64750 26Signed-off-by: Andrey Konovalov <andreyknvl@google.com> 27Bug: 135692346 28(cherry picked from commit f077ee260964eb925a593dcf30553432b3243ac8) 29 30Conflicts: 31 arch/arm64/Kconfig 32 arch/arm64/include/asm/processor.h 33 arch/arm64/include/asm/thread_info.h 34 arch/arm64/include/asm/uaccess.h 35 arch/arm64/kernel/process.c 36 include/uapi/linux/prctl.h 37 kernel/sys.c 38 39Only port definations to pass newest glibc compiling. 40 41Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 42--- 43 include/uapi/linux/prctl.h | 5 +++++ 44 1 file changed, 5 insertions(+) 45 46diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h 47index 4d05aad2e4c5..eabab9f1ee38 100644 48--- a/include/uapi/linux/prctl.h 49+++ b/include/uapi/linux/prctl.h 50@@ -219,4 +219,9 @@ struct prctl_mm_map { 51 # define PR_SPEC_DISABLE (1UL << 2) 52 # define PR_SPEC_FORCE_DISABLE (1UL << 3) 53 54+/* Tagged user address controls for arm64 */ 55+#define PR_SET_TAGGED_ADDR_CTRL 55 56+#define PR_GET_TAGGED_ADDR_CTRL 56 57+# define PR_TAGGED_ADDR_ENABLE (1UL << 0) 58+ 59 #endif /* _LINUX_PRCTL_H */ 60-- 612.20.1 62 63