From patchwork Mon Oct 17 20:17:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan McGee X-Patchwork-Id: 120443 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id E2A43100917 for ; Wed, 19 Oct 2011 02:04:40 +1100 (EST) Received: from mail-iy0-f179.google.com (mail-iy0-f179.google.com [209.85.210.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 094E5B70BB for ; Tue, 18 Oct 2011 07:18:01 +1100 (EST) Received: by iajr24 with SMTP id r24so7174503iaj.38 for ; Mon, 17 Oct 2011 13:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=Pn5e8ut+3MvCD02hD8seZ18Ni/IOc7g3x17xx2ORzek=; b=VR2h/STf1I26BGRMuLPcoSr+8nKfrAw0hrc2I/MlvhoPS93ItpXULvLdycdY8NlqcJ c9hIZOhG+sJnAl75LjF5ywI52BCekMtl5r+P/tnCwoRI966ekhZRcxowQ1tPb6IWYUxM GpRCJIns6hQ47PUtMG0Jajz9ASm2J/2NlQ888= Received: by 10.42.197.73 with SMTP id ej9mr42012346icb.2.1318882677367; Mon, 17 Oct 2011 13:17:57 -0700 (PDT) Received: from localhost (c-71-194-41-240.hsd1.il.comcast.net. [71.194.41.240]) by mx.google.com with ESMTPS id n30sm29831818ibl.4.2011.10.17.13.17.55 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Oct 2011 13:17:56 -0700 (PDT) From: Dan McGee To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc/mm: remove hack in mmap randomize layout Date: Mon, 17 Oct 2011 15:17:36 -0500 Message-Id: <1318882661-26859-1-git-send-email-dpmcgee@gmail.com> X-Mailer: git-send-email 1.7.7 X-Mailman-Approved-At: Wed, 19 Oct 2011 02:04:31 +1100 Cc: Paul Mackerras , linux-kernel@vger.kernel.org, Dan McGee X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Since commit 8a0a9bd4db63bc45e301, this comment in mmap_rnd() does not hold true as the value returned by get_random_int() will in fact be different every single call. Remove the comment and simplify the code back to its original desired form. This reverts commit a5adc91a4b44b5d1 which is no longer necessary. Signed-off-by: Dan McGee --- arch/powerpc/mm/mmap_64.c | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c index 5a783d8..67a42ed 100644 --- a/arch/powerpc/mm/mmap_64.c +++ b/arch/powerpc/mm/mmap_64.c @@ -53,14 +53,6 @@ static inline int mmap_is_legacy(void) return sysctl_legacy_va_layout; } -/* - * Since get_random_int() returns the same value within a 1 jiffy window, - * we will almost always get the same randomisation for the stack and mmap - * region. This will mean the relative distance between stack and mmap will - * be the same. - * - * To avoid this we can shift the randomness by 1 bit. - */ static unsigned long mmap_rnd(void) { unsigned long rnd = 0; @@ -68,11 +60,11 @@ static unsigned long mmap_rnd(void) if (current->flags & PF_RANDOMIZE) { /* 8MB for 32bit, 1GB for 64bit */ if (is_32bit_task()) - rnd = (long)(get_random_int() % (1<<(22-PAGE_SHIFT))); + rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT))); else - rnd = (long)(get_random_int() % (1<<(29-PAGE_SHIFT))); + rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT))); } - return (rnd << PAGE_SHIFT) * 2; + return rnd << PAGE_SHIFT; } static inline unsigned long mmap_base(void)