]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/arm64-compat-reduce-address-limit.patch
Linux 4.19.45
[thirdparty/kernel/stable-queue.git] / queue-5.0 / arm64-compat-reduce-address-limit.patch
1 From d263119387de9975d2acba1dfd3392f7c5979c18 Mon Sep 17 00:00:00 2001
2 From: Vincenzo Frascino <vincenzo.frascino@arm.com>
3 Date: Mon, 1 Apr 2019 12:30:14 +0100
4 Subject: arm64: compat: Reduce address limit
5
6 From: Vincenzo Frascino <vincenzo.frascino@arm.com>
7
8 commit d263119387de9975d2acba1dfd3392f7c5979c18 upstream.
9
10 Currently, compat tasks running on arm64 can allocate memory up to
11 TASK_SIZE_32 (UL(0x100000000)).
12
13 This means that mmap() allocations, if we treat them as returning an
14 array, are not compliant with the sections 6.5.8 of the C standard
15 (C99) which states that: "If the expression P points to an element of
16 an array object and the expression Q points to the last element of the
17 same array object, the pointer expression Q+1 compares greater than P".
18
19 Redefine TASK_SIZE_32 to address the issue.
20
21 Cc: Catalin Marinas <catalin.marinas@arm.com>
22 Cc: Will Deacon <will.deacon@arm.com>
23 Cc: Jann Horn <jannh@google.com>
24 Cc: <stable@vger.kernel.org>
25 Reported-by: Jann Horn <jannh@google.com>
26 Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
27 [will: fixed typo in comment]
28 Signed-off-by: Will Deacon <will.deacon@arm.com>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30
31 ---
32 arch/arm64/include/asm/processor.h | 8 ++++++++
33 1 file changed, 8 insertions(+)
34
35 --- a/arch/arm64/include/asm/processor.h
36 +++ b/arch/arm64/include/asm/processor.h
37 @@ -57,7 +57,15 @@
38 #define TASK_SIZE_64 (UL(1) << vabits_user)
39
40 #ifdef CONFIG_COMPAT
41 +#ifdef CONFIG_ARM64_64K_PAGES
42 +/*
43 + * With CONFIG_ARM64_64K_PAGES enabled, the last page is occupied
44 + * by the compat vectors page.
45 + */
46 #define TASK_SIZE_32 UL(0x100000000)
47 +#else
48 +#define TASK_SIZE_32 (UL(0x100000000) - PAGE_SIZE)
49 +#endif /* CONFIG_ARM64_64K_PAGES */
50 #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
51 TASK_SIZE_32 : TASK_SIZE_64)
52 #define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \