From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758102AbcBXUkr (ORCPT ); Wed, 24 Feb 2016 15:40:47 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:33211 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbcBXUkp (ORCPT ); Wed, 24 Feb 2016 15:40:45 -0500 Subject: Re: [PATCH 0/2] Fix mmap_base entropy for >31 bits. To: Kees Cook , Andrew Morton References: <1454623591-17951-1-git-send-email-dcashman@android.com> Cc: LKML , Russell King - ARM Linux , "Theodore Ts'o" , Arnd Bergmann , Greg KH , Catalin Marinas , Will Deacon , Ralf Baechle , "benh@kernel.crashing.org" , Paul Mackerras , Michael Ellerman , "David S. Miller" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "x86@kernel.org" , Al Viro , Nick Kralevich , Jeffrey Vander Stoep , Mark Salyzyn From: Daniel Cashman Message-ID: <56CE1549.1060505@android.com> Date: Wed, 24 Feb 2016 12:40:41 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/04/2016 02:29 PM, Kees Cook wrote: > On Thu, Feb 4, 2016 at 2:06 PM, Daniel Cashman wrote: >> Upstream commit: d07e22597d1d355829b7b18ac19afa912cf758d1 added the >> ability to choose from a range of values to use for entropy count in >> generating the random offset to the mmap_base address. The >> maximum value on this range was set to 32 bits for 64-bit x86 systems, >> but this value could be increased further, requiring more than the 32 >> bits of randomness provided by get_random_int(), as is already possible >> for arm64. Add a new function: get_random_long() which more naturally >> fits with the mmap usage of get_random_int() but operates exactly the >> same as get_random_int(). >> >> Also, fix the shifting constant in mmap_rnd() to be an unsigned long so >> that values greater than 31 bits generate an appropriate mask without >> overflow. This is especially important on x86, as its shift instruction >> uses a 5-bit mask for the shift operand, which meant that any value for >> mmap_rnd_bits over 31 acts as a no-op and effectively disables mmap_base >> randomization. >> >> Finally, replace calls to get_random_int() with get_random_long() where >> appropriate. >> >> Daniel Cashman (2): >> drivers: char: random: Add get_random_long(). >> use get_random_long(). >> >> arch/arm/mm/mmap.c | 2 +- >> arch/arm64/mm/mmap.c | 4 ++-- >> arch/mips/mm/mmap.c | 4 ++-- >> arch/powerpc/kernel/process.c | 4 ++-- >> arch/powerpc/mm/mmap.c | 4 ++-- >> arch/sparc/kernel/sys_sparc_64.c | 2 +- >> arch/x86/mm/mmap.c | 6 +++--- >> drivers/char/random.c | 22 ++++++++++++++++++++++ >> fs/binfmt_elf.c | 2 +- >> include/linux/random.h | 1 + >> 10 files changed, 37 insertions(+), 14 deletions(-) > > Thanks for fixing this! > > Acked-by: Kees Cook > > -Kees > This has now been in linux-next for awhile. Could we please submit this for the 4.5 rc window so that it fixes the issue in the final 4.5 release? Sorry if this is a protocol breach, but I'm not sure what the best way is for me to indicate that this is a "fix" that should go out in the same release as the original feature. Thank You, Dan