lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jJRVrMxgO0G2BjU2Ks=Pa1RcG3LidqXPe9zb-V1LbQv4g@mail.gmail.com>
Date:	Thu, 10 Mar 2016 12:23:36 -0800
From:	Kees Cook <keescook@...omium.org>
To:	Hector Marco-Gisbert <hecmargi@....es>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	"x86@...nel.org" <x86@...nel.org>,
	Ismael Ripoll Ripoll <iripoll@....es>,
	Harvey Harrison <harvey.harrison@...il.com>,
	Arjan van de Ven <arjan@...ux.intel.com>
Subject: Re: [PATCH] x86: Enable full randomization on i386 and X86_32.

On Thu, Mar 10, 2016 at 11:51 AM, Hector Marco-Gisbert <hecmargi@....es> wrote:
> Currently on i386 and on X86_64 when emulating X86_32 in legacy mode, only
> the stack and the executable are randomized but not other mmapped files
> (libraries, vDSO, etc.). This patch enables randomization for the
> libraries, vDSO and mmap requests on i386 and in X86_32 in legacy mode.
>
> By default on i386 there are 8 bits for the randomization of the libraries,
> vDSO and mmaps which only uses 1MB of VA.
>
> This patch preserves the original randomness, using 1MB of VA out of 3GB or
> 4GB. We think that 1MB out of 3GB is not a big cost for having the ASLR.
>
> The first obvious security benefit is that all objects are randomized (not
> only the stack and the executable) in legacy mode which highly increases
> the ASLR effectiveness, otherwise the attackers may use these
> non-randomized areas. But also sensitive setuid/setgid applications are
> more secure because currently, attackers can disable the randomization of
> these applications by setting the ulimit stack to "unlimited". This is a
> very old and widely known trick to disable the ASLR in i386 which has been
> allowed for too long.
>
> Another trick used to disable the ASLR was to set the ADDR_NO_RANDOMIZE
> personality flag, but fortunately this doesn't work on setuid/setgid
> applications because there is security checks which clear Security-relevant
> flags.
>
> This patch always randomizes the mmap_legacy_base address, removing the
> possibility to disable the ASLR by setting the stack to "unlimited".
>
>
> Signed-off-by: Hector Marco-Gisbert <hecmargi@....es>
> Signed-off-by: Ismael Ripoll Ripoll <iripoll@....es>

Thanks! This has bugged me for a long time. :)

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

Arjan, or other folks, can you remember why x86_32 disabled mmap
randomization here? There doesn't seem to be a good reason for it that
I see.

-Kees

> ---
>  arch/x86/mm/mmap.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
> index 72bb52f..d2dc043 100644
> --- a/arch/x86/mm/mmap.c
> +++ b/arch/x86/mm/mmap.c
> @@ -94,18 +94,6 @@ static unsigned long mmap_base(unsigned long rnd)
>  }
>
>  /*
> - * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
> - * does, but not when emulating X86_32
> - */
> -static unsigned long mmap_legacy_base(unsigned long rnd)
> -{
> -       if (mmap_is_ia32())
> -               return TASK_UNMAPPED_BASE;
> -       else
> -               return TASK_UNMAPPED_BASE + rnd;
> -}
> -
> -/*
>   * This function, called very early during the creation of a new
>   * process VM image, sets up which VM layout function to use:
>   */
> @@ -116,7 +104,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
>         if (current->flags & PF_RANDOMIZE)
>                 random_factor = arch_mmap_rnd();
>
> -       mm->mmap_legacy_base = mmap_legacy_base(random_factor);
> +       mm->mmap_legacy_base = TASK_UNMAPPED_BASE + random_factor;
>
>         if (mmap_is_legacy()) {
>                 mm->mmap_base = mm->mmap_legacy_base;
> --
> 1.9.1
>



-- 
Kees Cook
Chrome OS & Brillo Security

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ