linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] arm64: compat: Reduce address limit
@ 2019-04-01 11:30 Vincenzo Frascino
  2019-04-02 15:23 ` Catalin Marinas
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vincenzo Frascino @ 2019-04-01 11:30 UTC (permalink / raw)
  To: linux-arch, linux-arm-kernel
  Cc: Catalin Marinas, Will Deacon, stable, Jann Horn

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.
+ */
 #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) ? \
-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: compat: Reduce address limit
  2019-04-01 11:30 [PATCH v2] arm64: compat: Reduce address limit Vincenzo Frascino
@ 2019-04-02 15:23 ` Catalin Marinas
  2019-04-02 15:32 ` Will Deacon
  2019-04-02 15:48 ` Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2019-04-02 15:23 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arch, Will Deacon, stable, linux-arm-kernel, Jann Horn

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.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: compat: Reduce address limit
  2019-04-01 11:30 [PATCH v2] arm64: compat: Reduce address limit Vincenzo Frascino
  2019-04-02 15:23 ` Catalin Marinas
@ 2019-04-02 15:32 ` Will Deacon
  2019-04-02 15:48 ` Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2019-04-02 15:32 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arch, Catalin Marinas, stable, linux-arm-kernel, Jann Horn

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: compat: Reduce address limit
  2019-04-01 11:30 [PATCH v2] arm64: compat: Reduce address limit Vincenzo Frascino
  2019-04-02 15:23 ` Catalin Marinas
  2019-04-02 15:32 ` Will Deacon
@ 2019-04-02 15:48 ` Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-04-02 15:48 UTC (permalink / raw)
  To: Sasha Levin, Vincenzo Frascino, linux-arch, linux-arm-kernel
  Cc: Catalin Marinas, Will Deacon, stable, Jann Horn

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-02 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-01 11:30 [PATCH v2] arm64: compat: Reduce address limit Vincenzo Frascino
2019-04-02 15:23 ` Catalin Marinas
2019-04-02 15:32 ` Will Deacon
2019-04-02 15:48 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).