All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: compat: Reduce address limit
@ 2019-04-01 10:32 ` Vincenzo Frascino
  0 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2019-04-01 10:32 UTC (permalink / raw)
  To: linux-arch, linux-arm-kernel
  Cc: stable, Catalin Marinas, Will Deacon, 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>
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/processor.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 5d9ce62bdebd..f8235f7df29b 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -57,7 +57,11 @@
 #define TASK_SIZE_64		(UL(1) << vabits_user)
 
 #ifdef CONFIG_COMPAT
+#ifdef CONFIG_ARM64_64K_PAGES
 #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


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

* [PATCH] arm64: compat: Reduce address limit
@ 2019-04-01 10:32 ` Vincenzo Frascino
  0 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2019-04-01 10:32 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>
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/processor.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 5d9ce62bdebd..f8235f7df29b 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -57,7 +57,11 @@
 #define TASK_SIZE_64		(UL(1) << vabits_user)
 
 #ifdef CONFIG_COMPAT
+#ifdef CONFIG_ARM64_64K_PAGES
 #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] 6+ messages in thread

* Re: [PATCH] arm64: compat: Reduce address limit
  2019-04-01 10:32 ` Vincenzo Frascino
@ 2019-04-01 10:59   ` Catalin Marinas
  -1 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2019-04-01 10:59 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arch, linux-arm-kernel, stable, Will Deacon, Jann Horn

On Mon, Apr 01, 2019 at 11:32:01AM +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>
> Reported-by: Jann Horn <jannh@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/include/asm/processor.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 5d9ce62bdebd..f8235f7df29b 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -57,7 +57,11 @@
>  #define TASK_SIZE_64		(UL(1) << vabits_user)
>  
>  #ifdef CONFIG_COMPAT
> +#ifdef CONFIG_ARM64_64K_PAGES
>  #define TASK_SIZE_32		UL(0x100000000)
> +#else
> +#define TASK_SIZE_32		(UL(0x100000000) - PAGE_SIZE)
> +#endif /* CONFIG_ARM64_64K_PAGES */

I'd add a comment above stating that with the 64K page configuration,
the last page is occupied by the compat vectors page.

-- 
Catalin

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

* Re: [PATCH] arm64: compat: Reduce address limit
@ 2019-04-01 10:59   ` Catalin Marinas
  0 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2019-04-01 10:59 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arch, Will Deacon, stable, linux-arm-kernel, Jann Horn

On Mon, Apr 01, 2019 at 11:32:01AM +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>
> Reported-by: Jann Horn <jannh@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/include/asm/processor.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 5d9ce62bdebd..f8235f7df29b 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -57,7 +57,11 @@
>  #define TASK_SIZE_64		(UL(1) << vabits_user)
>  
>  #ifdef CONFIG_COMPAT
> +#ifdef CONFIG_ARM64_64K_PAGES
>  #define TASK_SIZE_32		UL(0x100000000)
> +#else
> +#define TASK_SIZE_32		(UL(0x100000000) - PAGE_SIZE)
> +#endif /* CONFIG_ARM64_64K_PAGES */

I'd add a comment above stating that with the 64K page configuration,
the last page is occupied by the compat vectors page.

-- 
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] 6+ messages in thread

* Re: [PATCH] arm64: compat: Reduce address limit
  2019-04-01 10:59   ` Catalin Marinas
@ 2019-04-01 11:27     ` Vincenzo Frascino
  -1 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2019-04-01 11:27 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arch, linux-arm-kernel, stable, Will Deacon, Jann Horn

On 01/04/2019 11:59, Catalin Marinas wrote:
> On Mon, Apr 01, 2019 at 11:32:01AM +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>
>> Reported-by: Jann Horn <jannh@google.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>  arch/arm64/include/asm/processor.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
>> index 5d9ce62bdebd..f8235f7df29b 100644
>> --- a/arch/arm64/include/asm/processor.h
>> +++ b/arch/arm64/include/asm/processor.h
>> @@ -57,7 +57,11 @@
>>  #define TASK_SIZE_64		(UL(1) << vabits_user)
>>  
>>  #ifdef CONFIG_COMPAT
>> +#ifdef CONFIG_ARM64_64K_PAGES
>>  #define TASK_SIZE_32		UL(0x100000000)
>> +#else
>> +#define TASK_SIZE_32		(UL(0x100000000) - PAGE_SIZE)
>> +#endif /* CONFIG_ARM64_64K_PAGES */
> 
> I'd add a comment above stating that with the 64K page configuration,
> the last page is occupied by the compat vectors page.
> 

Ok, I will post v2 shortly.

-- 
Regards,
Vincenzo

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

* Re: [PATCH] arm64: compat: Reduce address limit
@ 2019-04-01 11:27     ` Vincenzo Frascino
  0 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2019-04-01 11:27 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arch, Will Deacon, stable, linux-arm-kernel, Jann Horn

On 01/04/2019 11:59, Catalin Marinas wrote:
> On Mon, Apr 01, 2019 at 11:32:01AM +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>
>> Reported-by: Jann Horn <jannh@google.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>  arch/arm64/include/asm/processor.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
>> index 5d9ce62bdebd..f8235f7df29b 100644
>> --- a/arch/arm64/include/asm/processor.h
>> +++ b/arch/arm64/include/asm/processor.h
>> @@ -57,7 +57,11 @@
>>  #define TASK_SIZE_64		(UL(1) << vabits_user)
>>  
>>  #ifdef CONFIG_COMPAT
>> +#ifdef CONFIG_ARM64_64K_PAGES
>>  #define TASK_SIZE_32		UL(0x100000000)
>> +#else
>> +#define TASK_SIZE_32		(UL(0x100000000) - PAGE_SIZE)
>> +#endif /* CONFIG_ARM64_64K_PAGES */
> 
> I'd add a comment above stating that with the 64K page configuration,
> the last page is occupied by the compat vectors page.
> 

Ok, I will post v2 shortly.

-- 
Regards,
Vincenzo

_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2019-04-01 11:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-01 10:32 [PATCH] arm64: compat: Reduce address limit Vincenzo Frascino
2019-04-01 10:32 ` Vincenzo Frascino
2019-04-01 10:59 ` Catalin Marinas
2019-04-01 10:59   ` Catalin Marinas
2019-04-01 11:27   ` Vincenzo Frascino
2019-04-01 11:27     ` Vincenzo Frascino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.