Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753599Ab1B1XTR (ORCPT ); Mon, 28 Feb 2011 18:19:17 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:37931 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752696Ab1B1XTQ (ORCPT ); Mon, 28 Feb 2011 18:19:16 -0500 Date: Mon, 28 Feb 2011 15:18:25 -0800 From: Andrew Morton To: Ludwig Nussel Cc: linux-kernel@vger.kernel.org, security@kernel.org, x86@kernel.org, Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner Subject: Re: [Security] [PATCH] fix mmap random address range on x86 Message-Id: <20110228151825.26458ec9.akpm@linux-foundation.org> In-Reply-To: <1298034957-17128-1-git-send-email-ludwig.nussel@suse.de> References: <1298034957-17128-1-git-send-email-ludwig.nussel@suse.de> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1598 Lines: 45 On Fri, 18 Feb 2011 14:15:57 +0100 Ludwig Nussel wrote: > On x86 casting the unsigned int result of get_random_int() to long > may result in a negative value. On x86 the range of mmap_rnd() > therefore was -255 to 255. The 32bit mode on x86_64 used 0 to 255 as > intended. > > The bug was introduced by commit 675a081 in January 2008. > > Signed-off-by: Ludwig Nussel > --- > arch/x86/mm/mmap.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c > index 1dab519..f927429 100644 > --- a/arch/x86/mm/mmap.c > +++ b/arch/x86/mm/mmap.c > @@ -87,9 +87,9 @@ static unsigned long mmap_rnd(void) > */ > if (current->flags & PF_RANDOMIZE) { > if (mmap_is_ia32()) > - rnd = (long)get_random_int() % (1<<8); > + rnd = get_random_int() % (1<<8); > else > - rnd = (long)(get_random_int() % (1<<28)); > + rnd = get_random_int() % (1<<28); > } > return rnd << PAGE_SHIFT; > } The changelog didn't describe the user-visible consequences of this bug, so readers must try to work this out for themselves. That's not a very desirable or efficient thing, so please do prepare more complete changelogs. afacit the effects are very small: the mmap base may fall slightly below MIN_GAP, but that won't really affect anything? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/