Message ID | 20190401113014.20866-1-vincenzo.frascino@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] arm64: compat: Reduce address limit | expand |
On Mon, Apr 01, 2019 at 12:30:14PM +0100, Vincenzo Frascino wrote: > 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> I'll queue this patch for -rc4.
On Mon, Apr 01, 2019 at 12:30:14PM +0100, Vincenzo Frascino wrote: > 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> > --- > arch/arm64/include/asm/processor.h | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h > index 5d9ce62bdebd..9c831d9d3cd2 100644 > --- a/arch/arm64/include/asm/processor.h > +++ b/arch/arm64/include/asm/processor.h > @@ -57,7 +57,15 @@ > #define TASK_SIZE_64 (UL(1) << vabits_user) > > #ifdef CONFIG_COMPAT > +#ifdef CONFIG_ARM64_64K_PAGES > +/* > + * With CONFIG_ARM64_64K_PAGES enabled, the last page is occupied > + * by the compact vectors page. s/compact/compat/ Will
Hi, [This is an automated email] This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all The bot has tested the following trees: v5.0.5, v4.19.32, v4.14.109, v4.9.166, v4.4.177, v3.18.137. v5.0.5: Build OK! v4.19.32: Build OK! v4.14.109: Build OK! v4.9.166: Build OK! v4.4.177: Failed to apply! Possible dependencies: 132cd887b5c5 ("arm64: Modify stack trace and dump for use with irq_stack") 39bc88e5e38e ("arm64: Disable TTBR0_EL1 during normal kernel execution") 4dffbfc48d65 ("arm64/efi: mark UEFI reserved regions as MEMBLOCK_NOMAP") 57f4959bad0a ("arm64: kernel: Add support for User Access Override") 705441960033 ("arm64: kernel: Don't toggle PAN on systems with UAO") 7dd01aef0557 ("arm64: trap userspace "dc cvau" cache operation on errata-affected core") 87261d19046a ("arm64: Cortex-A53 errata workaround: check for kernel addresses") 8e23dacd12a4 ("arm64: Add do_softirq_own_stack() and enable irq_stacks") 9e8e865bbe29 ("arm64: unify idmap removal") bffe1baff5d5 ("arm64: kasan: instrument user memory access API") d5370f754875 ("arm64: prefetch: add alternative pattern for CPUs without a prefetcher") e5bc22a42e4d ("arm64/efi: split off EFI init and runtime code for reuse by 32-bit ARM") e7227d0e528f ("arm64: Cleanup SCTLR flags") eef94a3d09aa ("arm64: move TASK_* definitions to <asm/processor.h>") f7d924894265 ("arm64/efi: refactor EFI init and runtime code for reuse by 32-bit ARM") v3.18.137: Failed to apply! Possible dependencies: 04597a65c5ef ("arm64: Track system support for mixed endian EL0") 127db024a7ba ("arm64: introduce VA_START macro - the first kernel virtual address.") 1b907f46db07 ("arm64: kconfig: move emulation option under kernel features") 2d888f48e056 ("arm64: Emulate SETEND for AArch32 tasks") 338d4f49d6f7 ("arm64: kernel: Add support for Privileged Access Never") 359b706473b4 ("arm64: Extract feature parsing code from cpu_errata.c") 587064b610c7 ("arm64: Add framework for legacy instruction emulation") 736d474f0faf ("arm64: Consolidate hotplug notifier for instruction emulation") 870828e57b14 ("arm64: kernel: Move config_sctlr_el1") 94a9e04aa16a ("arm64: alternative: Introduce feature for GICv3 CPU interface") 9b79f52d1a70 ("arm64: Add support for hooks to handle undefined instructions") aa03c428e678 ("arm64: Fix overlapping VA allocations") bd35a4adc413 ("arm64: Port SWP/SWPB emulation support from arm") c852f3205846 ("arm64: Emulate CP15 Barrier instructions") c9453a3ab1a3 ("arm64: alternatives: fix pr_fmt string for consistency") c9465b4ec37a ("arm64: add support to dump the kernel page tables") eef94a3d09aa ("arm64: move TASK_* definitions to <asm/processor.h>") How should we proceed with this patch? -- Thanks, Sasha
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 5d9ce62bdebd..9c831d9d3cd2 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -57,7 +57,15 @@ #define TASK_SIZE_64 (UL(1) << vabits_user) #ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_64K_PAGES +/* + * With CONFIG_ARM64_64K_PAGES enabled, the last page is occupied + * by the compact vectors page. + */ #define TASK_SIZE_32 UL(0x100000000) +#else +#define TASK_SIZE_32 (UL(0x100000000) - PAGE_SIZE) +#endif /* CONFIG_ARM64_64K_PAGES */ #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ TASK_SIZE_32 : TASK_SIZE_64) #define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
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> --- arch/arm64/include/asm/processor.h | 8 ++++++++ 1 file changed, 8 insertions(+)