Skip to content

Commit d263119

Browse files
fvincenzowildea01
authored andcommitted
arm64: compat: Reduce address limit
Currently, compat tasks running on arm64 can allocate memory up to TASK_SIZE_32 (UL(0x100000000)). This means that mmap() allocations, if we treat them as returning an array, are not compliant with the sections 6.5.8 of the C standard (C99) which states that: "If the expression P points to an element of an array object and the expression Q points to the last element of the same array object, the pointer expression Q+1 compares greater than P". Redefine TASK_SIZE_32 to address the issue. Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Jann Horn <jannh@google.com> Cc: <stable@vger.kernel.org> Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com> [will: fixed typo in comment] Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 827a108 commit d263119

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/arm64/include/asm/processor.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@
5757
#define TASK_SIZE_64 (UL(1) << vabits_user)
5858

5959
#ifdef CONFIG_COMPAT
60+
#ifdef CONFIG_ARM64_64K_PAGES
61+
/*
62+
* With CONFIG_ARM64_64K_PAGES enabled, the last page is occupied
63+
* by the compat vectors page.
64+
*/
6065
#define TASK_SIZE_32 UL(0x100000000)
66+
#else
67+
#define TASK_SIZE_32 (UL(0x100000000) - PAGE_SIZE)
68+
#endif /* CONFIG_ARM64_64K_PAGES */
6169
#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
6270
TASK_SIZE_32 : TASK_SIZE_64)
6371
#define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \

0 commit comments

Comments
 (0)