Re: [PATCH] ASLRv3: randomize_va_space=3 preventing offset2lib attack

From: Christian Borntraeger
Date: Mon Dec 08 2014 - 15:09:32 EST


Am 05.12.2014 um 01:07 schrieb Hector Marco:
> [PATCH] ASLRv3: randomize_va_space=3 preventing offset2lib attack
>
> The issue appears on PIE linked executables when all memory areas of
> a process are randomized (randomize_va_space=2). In this case, the
> attack "offset2lib" de-randomizes all library areas on 64 bit Linux
> systems in less than one second.
>
> Further details of the PoC attack at:
> http://cybersecurity.upv.es/attacks/offset2lib/offset2lib.html
>
> PIE linked applications are loaded side by side with the dynamic
> libraries, which is exploited by the offset2lib attack. Moving away
> the executable from the mmap_base area (libraries area) prevents the
> attack.
>
> This patch loads the PIE linked executable in a different area than
> the libraries when randomize_va_space=3.
>
> Patch implementation details:
>
> - The ELF_ET_DYN_BASE address is used as the base to load randomly
> the PIE executable.
>
> - The executable image has the same entropy than
> randomize_va_space=2.
[...]
> --- a/arch/arm/mm/mmap.c
> +++ b/arch/arm/mm/mmap.c
[...]
> --- a/arch/arm64/mm/mmap.c
> +++ b/arch/arm64/mm/mmap.c
[...]

> --- a/arch/x86/mm/mmap.c
> +++ b/arch/x86/mm/mmap.c
[...]

FWIW, please note that s390 and power (maybe others?) also have PIE support done differently, e.g.
commit d2c9dfccbc3 ("[S390] Randomize PIEs") and commit 501cb16d3cfdc ("powerpc: Randomise PIEs")

What I can tell from a quick look both architectures should be fine regarding offsetlib, as they place the executable already in a different section and randomize those differently even with randomize_va_space=2.

Would it make sense to unify the implementations again?

Christian

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/