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