All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
@ 2015-03-20 11:12 ` Andrey Ryabinin
  0 siblings, 0 replies; 13+ messages in thread
From: Andrey Ryabinin @ 2015-03-20 11:12 UTC (permalink / raw)
  To: Russell King
  Cc: Kees Cook, linux-arm-kernel, linux-kernel, Maria Guseva,
	Yury Gribov, Andrey Ryabinin, stable

Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
split this is not so, because 2*TASK_SIZE overflows 32 bits,
so the actual value of ELF_ET_DYN_BASE is:
	(2 * TASK_SIZE / 3) = 0x2a000000

When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
as it fails to map shadow memory.
Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
even if ASLR enabled. This makes ASan with PIE absolutely incompatible.

Fix overflow by dividing TASK_SIZE prior to multiplying.
After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
	(TASK_SIZE / 3 * 2) = 0x7f555554

[1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping

Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Reported-by: Maria Guseva <m.guseva@samsung.com>
Cc: stable@vger.kernel.org
---
 arch/arm/include/asm/elf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index c1ff8ab..1984a92 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -115,7 +115,7 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
    the loader.  We need to make sure that it is out of the way of the program
    that it will "exec", and that there is sufficient room for the brk.  */
 
-#define ELF_ET_DYN_BASE	(2 * TASK_SIZE / 3)
+#define ELF_ET_DYN_BASE	(TASK_SIZE / 3 * 2)
 
 /* When the program starts, a1 contains a pointer to a function to be 
    registered with atexit, as per the SVR4 ABI.  A value of 0 means we 
-- 
2.3.3


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

* [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
@ 2015-03-20 11:12 ` Andrey Ryabinin
  0 siblings, 0 replies; 13+ messages in thread
From: Andrey Ryabinin @ 2015-03-20 11:12 UTC (permalink / raw)
  To: linux-arm-kernel

Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
split this is not so, because 2*TASK_SIZE overflows 32 bits,
so the actual value of ELF_ET_DYN_BASE is:
	(2 * TASK_SIZE / 3) = 0x2a000000

When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
as it fails to map shadow memory.
Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
even if ASLR enabled. This makes ASan with PIE absolutely incompatible.

Fix overflow by dividing TASK_SIZE prior to multiplying.
After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
	(TASK_SIZE / 3 * 2) = 0x7f555554

[1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping

Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Reported-by: Maria Guseva <m.guseva@samsung.com>
Cc: stable at vger.kernel.org
---
 arch/arm/include/asm/elf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index c1ff8ab..1984a92 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -115,7 +115,7 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
    the loader.  We need to make sure that it is out of the way of the program
    that it will "exec", and that there is sufficient room for the brk.  */
 
-#define ELF_ET_DYN_BASE	(2 * TASK_SIZE / 3)
+#define ELF_ET_DYN_BASE	(TASK_SIZE / 3 * 2)
 
 /* When the program starts, a1 contains a pointer to a function to be 
    registered with atexit, as per the SVR4 ABI.  A value of 0 means we 
-- 
2.3.3

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

* Re: [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
  2015-03-20 11:12 ` Andrey Ryabinin
@ 2015-03-20 11:31   ` Yury Gribov
  -1 siblings, 0 replies; 13+ messages in thread
From: Yury Gribov @ 2015-03-20 11:31 UTC (permalink / raw)
  To: Andrey Ryabinin, Russell King
  Cc: Kees Cook, linux-arm-kernel, linux-kernel, Maria Guseva, stable

On 03/20/2015 02:12 PM, Andrey Ryabinin wrote:
> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
> split this is not so, because 2*TASK_SIZE overflows 32 bits,
> so the actual value of ELF_ET_DYN_BASE is:
> 	(2 * TASK_SIZE / 3) = 0x2a000000

AFAIK on most platforms (e.g. Intel) that's (TASK_SIZE / 3 * 2) so ARM 
is kind of special here.

>
> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
> as it fails to map shadow memory.
> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>
> Fix overflow by dividing TASK_SIZE prior to multiplying.
> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
> 	(TASK_SIZE / 3 * 2) = 0x7f555554
>
> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping

Perhaps we should fix other platforms as well?

-Y

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

* [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
@ 2015-03-20 11:31   ` Yury Gribov
  0 siblings, 0 replies; 13+ messages in thread
From: Yury Gribov @ 2015-03-20 11:31 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/20/2015 02:12 PM, Andrey Ryabinin wrote:
> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
> split this is not so, because 2*TASK_SIZE overflows 32 bits,
> so the actual value of ELF_ET_DYN_BASE is:
> 	(2 * TASK_SIZE / 3) = 0x2a000000

AFAIK on most platforms (e.g. Intel) that's (TASK_SIZE / 3 * 2) so ARM 
is kind of special here.

>
> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
> as it fails to map shadow memory.
> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>
> Fix overflow by dividing TASK_SIZE prior to multiplying.
> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
> 	(TASK_SIZE / 3 * 2) = 0x7f555554
>
> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping

Perhaps we should fix other platforms as well?

-Y

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

* Re: [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
  2015-03-20 11:31   ` Yury Gribov
@ 2015-03-20 11:42     ` Andrey Ryabinin
  -1 siblings, 0 replies; 13+ messages in thread
From: Andrey Ryabinin @ 2015-03-20 11:42 UTC (permalink / raw)
  To: Yury Gribov
  Cc: Russell King, Kees Cook, linux-arm-kernel, linux-kernel,
	Maria Guseva, stable

On 03/20/2015 02:31 PM, Yury Gribov wrote:
> On 03/20/2015 02:12 PM, Andrey Ryabinin wrote:
>> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
>> split this is not so, because 2*TASK_SIZE overflows 32 bits,
>> so the actual value of ELF_ET_DYN_BASE is:
>>     (2 * TASK_SIZE / 3) = 0x2a000000
> 
> AFAIK on most platforms (e.g. Intel) that's (TASK_SIZE / 3 * 2) so ARM is kind of special here.
> 
>>
>> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
>> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
>> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
>> as it fails to map shadow memory.
>> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
>> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
>> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>>
>> Fix overflow by dividing TASK_SIZE prior to multiplying.
>> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
>>     (TASK_SIZE / 3 * 2) = 0x7f555554
>>
>> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
> 
> Perhaps we should fix other platforms as well?
> 

Seems only avr32 and cris platforms have the same problem.
All other 32bit platforms where ELF_ET_DYB_BASE = (2 * TASK_SIZE / 3) have TASK_SIZE < 2G, so there is no overflow.


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

* [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
@ 2015-03-20 11:42     ` Andrey Ryabinin
  0 siblings, 0 replies; 13+ messages in thread
From: Andrey Ryabinin @ 2015-03-20 11:42 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/20/2015 02:31 PM, Yury Gribov wrote:
> On 03/20/2015 02:12 PM, Andrey Ryabinin wrote:
>> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
>> split this is not so, because 2*TASK_SIZE overflows 32 bits,
>> so the actual value of ELF_ET_DYN_BASE is:
>>     (2 * TASK_SIZE / 3) = 0x2a000000
> 
> AFAIK on most platforms (e.g. Intel) that's (TASK_SIZE / 3 * 2) so ARM is kind of special here.
> 
>>
>> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
>> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
>> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
>> as it fails to map shadow memory.
>> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
>> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
>> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>>
>> Fix overflow by dividing TASK_SIZE prior to multiplying.
>> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
>>     (TASK_SIZE / 3 * 2) = 0x7f555554
>>
>> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
> 
> Perhaps we should fix other platforms as well?
> 

Seems only avr32 and cris platforms have the same problem.
All other 32bit platforms where ELF_ET_DYB_BASE = (2 * TASK_SIZE / 3) have TASK_SIZE < 2G, so there is no overflow.

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

* Re: [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
  2015-03-20 11:12 ` Andrey Ryabinin
  (?)
@ 2015-03-23 18:16   ` Kees Cook
  -1 siblings, 0 replies; 13+ messages in thread
From: Kees Cook @ 2015-03-23 18:16 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: Russell King, linux-arm-kernel, LKML, Maria Guseva, Yury Gribov, # 3.4.x

On Fri, Mar 20, 2015 at 4:12 AM, Andrey Ryabinin <a.ryabinin@samsung.com> wrote:
> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
> split this is not so, because 2*TASK_SIZE overflows 32 bits,
> so the actual value of ELF_ET_DYN_BASE is:
>         (2 * TASK_SIZE / 3) = 0x2a000000
>
> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
> as it fails to map shadow memory.
> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>
> Fix overflow by dividing TASK_SIZE prior to multiplying.
> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
>         (TASK_SIZE / 3 * 2) = 0x7f555554
>
> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
>
> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
> Reported-by: Maria Guseva <m.guseva@samsung.com>
> Cc: stable@vger.kernel.org
> ---
>  arch/arm/include/asm/elf.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
> index c1ff8ab..1984a92 100644
> --- a/arch/arm/include/asm/elf.h
> +++ b/arch/arm/include/asm/elf.h
> @@ -115,7 +115,7 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
>     the loader.  We need to make sure that it is out of the way of the program
>     that it will "exec", and that there is sufficient room for the brk.  */
>
> -#define ELF_ET_DYN_BASE        (2 * TASK_SIZE / 3)
> +#define ELF_ET_DYN_BASE        (TASK_SIZE / 3 * 2)
>
>  /* When the program starts, a1 contains a pointer to a function to be
>     registered with atexit, as per the SVR4 ABI.  A value of 0 means we

Acked-by: Kees Cook <keescook@chromium.org>

Though, yes, as mentioned in the other replies, please send fixes for
the other architectures too.

Thanks for catching this!

-Kees

-- 
Kees Cook
Chrome OS Security

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

* Re: [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
@ 2015-03-23 18:16   ` Kees Cook
  0 siblings, 0 replies; 13+ messages in thread
From: Kees Cook @ 2015-03-23 18:16 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: Russell King, linux-arm-kernel, LKML, Maria Guseva, Yury Gribov, # 3.4.x

On Fri, Mar 20, 2015 at 4:12 AM, Andrey Ryabinin <a.ryabinin@samsung.com> wrote:
> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
> split this is not so, because 2*TASK_SIZE overflows 32 bits,
> so the actual value of ELF_ET_DYN_BASE is:
>         (2 * TASK_SIZE / 3) = 0x2a000000
>
> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
> as it fails to map shadow memory.
> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>
> Fix overflow by dividing TASK_SIZE prior to multiplying.
> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
>         (TASK_SIZE / 3 * 2) = 0x7f555554
>
> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
>
> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
> Reported-by: Maria Guseva <m.guseva@samsung.com>
> Cc: stable@vger.kernel.org
> ---
>  arch/arm/include/asm/elf.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
> index c1ff8ab..1984a92 100644
> --- a/arch/arm/include/asm/elf.h
> +++ b/arch/arm/include/asm/elf.h
> @@ -115,7 +115,7 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
>     the loader.  We need to make sure that it is out of the way of the program
>     that it will "exec", and that there is sufficient room for the brk.  */
>
> -#define ELF_ET_DYN_BASE        (2 * TASK_SIZE / 3)
> +#define ELF_ET_DYN_BASE        (TASK_SIZE / 3 * 2)
>
>  /* When the program starts, a1 contains a pointer to a function to be
>     registered with atexit, as per the SVR4 ABI.  A value of 0 means we

Acked-by: Kees Cook <keescook@chromium.org>

Though, yes, as mentioned in the other replies, please send fixes for
the other architectures too.

Thanks for catching this!

-Kees

-- 
Kees Cook
Chrome OS Security

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

* [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
@ 2015-03-23 18:16   ` Kees Cook
  0 siblings, 0 replies; 13+ messages in thread
From: Kees Cook @ 2015-03-23 18:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 20, 2015 at 4:12 AM, Andrey Ryabinin <a.ryabinin@samsung.com> wrote:
> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
> split this is not so, because 2*TASK_SIZE overflows 32 bits,
> so the actual value of ELF_ET_DYN_BASE is:
>         (2 * TASK_SIZE / 3) = 0x2a000000
>
> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
> as it fails to map shadow memory.
> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>
> Fix overflow by dividing TASK_SIZE prior to multiplying.
> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
>         (TASK_SIZE / 3 * 2) = 0x7f555554
>
> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
>
> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
> Reported-by: Maria Guseva <m.guseva@samsung.com>
> Cc: stable at vger.kernel.org
> ---
>  arch/arm/include/asm/elf.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
> index c1ff8ab..1984a92 100644
> --- a/arch/arm/include/asm/elf.h
> +++ b/arch/arm/include/asm/elf.h
> @@ -115,7 +115,7 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
>     the loader.  We need to make sure that it is out of the way of the program
>     that it will "exec", and that there is sufficient room for the brk.  */
>
> -#define ELF_ET_DYN_BASE        (2 * TASK_SIZE / 3)
> +#define ELF_ET_DYN_BASE        (TASK_SIZE / 3 * 2)
>
>  /* When the program starts, a1 contains a pointer to a function to be
>     registered with atexit, as per the SVR4 ABI.  A value of 0 means we

Acked-by: Kees Cook <keescook@chromium.org>

Though, yes, as mentioned in the other replies, please send fixes for
the other architectures too.

Thanks for catching this!

-Kees

-- 
Kees Cook
Chrome OS Security

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

* Re: [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
  2015-03-20 11:12 ` Andrey Ryabinin
@ 2015-03-26 15:05   ` Russell King - ARM Linux
  -1 siblings, 0 replies; 13+ messages in thread
From: Russell King - ARM Linux @ 2015-03-26 15:05 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: Kees Cook, linux-arm-kernel, linux-kernel, Maria Guseva,
	Yury Gribov, stable

On Fri, Mar 20, 2015 at 02:12:52PM +0300, Andrey Ryabinin wrote:
> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
> split this is not so, because 2*TASK_SIZE overflows 32 bits,
> so the actual value of ELF_ET_DYN_BASE is:
> 	(2 * TASK_SIZE / 3) = 0x2a000000
> 
> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
> as it fails to map shadow memory.
> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
> 
> Fix overflow by dividing TASK_SIZE prior to multiplying.
> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
> 	(TASK_SIZE / 3 * 2) = 0x7f555554
> 
> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
> 
> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
> Reported-by: Maria Guseva <m.guseva@samsung.com>
> Cc: stable@vger.kernel.org

Who's handling this patch?  I'm guessing it should be me, so if it could
find its way into my patch system for when I next apply a bunch of patches,
that'd be good.

Thanks.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
@ 2015-03-26 15:05   ` Russell King - ARM Linux
  0 siblings, 0 replies; 13+ messages in thread
From: Russell King - ARM Linux @ 2015-03-26 15:05 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 20, 2015 at 02:12:52PM +0300, Andrey Ryabinin wrote:
> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
> split this is not so, because 2*TASK_SIZE overflows 32 bits,
> so the actual value of ELF_ET_DYN_BASE is:
> 	(2 * TASK_SIZE / 3) = 0x2a000000
> 
> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
> as it fails to map shadow memory.
> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
> 
> Fix overflow by dividing TASK_SIZE prior to multiplying.
> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
> 	(TASK_SIZE / 3 * 2) = 0x7f555554
> 
> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
> 
> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
> Reported-by: Maria Guseva <m.guseva@samsung.com>
> Cc: stable at vger.kernel.org

Who's handling this patch?  I'm guessing it should be me, so if it could
find its way into my patch system for when I next apply a bunch of patches,
that'd be good.

Thanks.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
  2015-03-26 15:05   ` Russell King - ARM Linux
@ 2015-03-26 15:19     ` Andrey Ryabinin
  -1 siblings, 0 replies; 13+ messages in thread
From: Andrey Ryabinin @ 2015-03-26 15:19 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Kees Cook, linux-arm-kernel, linux-kernel, Maria Guseva,
	Yury Gribov, stable

On 03/26/2015 06:05 PM, Russell King - ARM Linux wrote:
> On Fri, Mar 20, 2015 at 02:12:52PM +0300, Andrey Ryabinin wrote:
>> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
>> split this is not so, because 2*TASK_SIZE overflows 32 bits,
>> so the actual value of ELF_ET_DYN_BASE is:
>> 	(2 * TASK_SIZE / 3) = 0x2a000000
>>
>> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
>> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
>> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
>> as it fails to map shadow memory.
>> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
>> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
>> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>>
>> Fix overflow by dividing TASK_SIZE prior to multiplying.
>> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
>> 	(TASK_SIZE / 3 * 2) = 0x7f555554
>>
>> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
>>
>> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
>> Reported-by: Maria Guseva <m.guseva@samsung.com>
>> Cc: stable@vger.kernel.org
> 
> Who's handling this patch?  I'm guessing it should be me, so if it could
> find its way into my patch system for when I next apply a bunch of patches,
> that'd be good.
> 

It's already there. Patch number - 8320/1.


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

* [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE
@ 2015-03-26 15:19     ` Andrey Ryabinin
  0 siblings, 0 replies; 13+ messages in thread
From: Andrey Ryabinin @ 2015-03-26 15:19 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/26/2015 06:05 PM, Russell King - ARM Linux wrote:
> On Fri, Mar 20, 2015 at 02:12:52PM +0300, Andrey Ryabinin wrote:
>> Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel
>> split this is not so, because 2*TASK_SIZE overflows 32 bits,
>> so the actual value of ELF_ET_DYN_BASE is:
>> 	(2 * TASK_SIZE / 3) = 0x2a000000
>>
>> When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address.
>> On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000]
>> for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled
>> as it fails to map shadow memory.
>> Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries
>> has a high chance of loading somewhere in between [0x2a000000 - 0x40000000]
>> even if ASLR enabled. This makes ASan with PIE absolutely incompatible.
>>
>> Fix overflow by dividing TASK_SIZE prior to multiplying.
>> After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y):
>> 	(TASK_SIZE / 3 * 2) = 0x7f555554
>>
>> [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping
>>
>> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
>> Reported-by: Maria Guseva <m.guseva@samsung.com>
>> Cc: stable at vger.kernel.org
> 
> Who's handling this patch?  I'm guessing it should be me, so if it could
> find its way into my patch system for when I next apply a bunch of patches,
> that'd be good.
> 

It's already there. Patch number - 8320/1.

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

end of thread, other threads:[~2015-03-26 15:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-20 11:12 [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE Andrey Ryabinin
2015-03-20 11:12 ` Andrey Ryabinin
2015-03-20 11:31 ` Yury Gribov
2015-03-20 11:31   ` Yury Gribov
2015-03-20 11:42   ` Andrey Ryabinin
2015-03-20 11:42     ` Andrey Ryabinin
2015-03-23 18:16 ` Kees Cook
2015-03-23 18:16   ` Kees Cook
2015-03-23 18:16   ` Kees Cook
2015-03-26 15:05 ` Russell King - ARM Linux
2015-03-26 15:05   ` Russell King - ARM Linux
2015-03-26 15:19   ` Andrey Ryabinin
2015-03-26 15:19     ` Andrey Ryabinin

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.