From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753485AbcGYSyJ (ORCPT ); Mon, 25 Jul 2016 14:54:09 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:37317 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752933AbcGYSyG (ORCPT ); Mon, 25 Jul 2016 14:54:06 -0400 MIME-Version: 1.0 In-Reply-To: <1469471141-25669-1-git-send-email-william.c.roberts@intel.com> References: <1469471141-25669-1-git-send-email-william.c.roberts@intel.com> From: Kees Cook Date: Mon, 25 Jul 2016 11:54:02 -0700 X-Google-Sender-Auth: rDGLR1UHvw4YRsLYGl5I5L4u1Cw Message-ID: Subject: Re: [PATCH] randomize_range: use random long instead of int To: "Roberts, William C" , Andrew Morton Cc: linux-mm@vger.kernel.org, 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 , Daniel Cashman Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 25, 2016 at 11:25 AM, wrote: > From: William Roberts > > Use a long when generating the random range rather than > an int. This will produce better random distributions as > well as matching all the types at hand. > > Signed-off-by: William Roberts I agree, this is what I pointed out back in Feb: https://lkml.org/lkml/2016/2/4/854 Acked-by: Kees Cook Andrew, can you pick this up for 4.8? -Kees > --- > drivers/char/random.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/char/random.c b/drivers/char/random.c > index 0158d3b..bbf11b5 100644 > --- a/drivers/char/random.c > +++ b/drivers/char/random.c > @@ -1837,7 +1837,8 @@ randomize_range(unsigned long start, unsigned long end, unsigned long len) > > if (end <= start + len) > return 0; > - return PAGE_ALIGN(get_random_int() % range + start); > + > + return PAGE_ALIGN(get_random_long() % range + start); > } > > /* Interface for in-kernel drivers of true hardware RNGs. > -- > 1.9.1 > -- Kees Cook Chrome OS & Brillo Security