From patchwork Mon Nov 17 23:02:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 5324361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7FE6C9F2ED for ; Mon, 17 Nov 2014 23:05:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7E3120127 for ; Mon, 17 Nov 2014 23:05:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF57F2011D for ; Mon, 17 Nov 2014 23:05:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqVKT-0004eC-Sw; Mon, 17 Nov 2014 23:03:29 +0000 Received: from smtp6-g21.free.fr ([2a01:e0c:1:1599::15]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqVKQ-0004c5-Rd for linux-arm-kernel@lists.infradead.org; Mon, 17 Nov 2014 23:03:27 +0000 Received: from localhost.localdomain (unknown [IPv6:2a01:e35:2e9f:6ac0:9c63:d888:b6bc:de5]) by smtp6-g21.free.fr (Postfix) with ESMTP id E3E46822AE; Tue, 18 Nov 2014 00:02:31 +0100 (CET) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.8/8.14.8) with ESMTP id sAHN2dT7008178; Tue, 18 Nov 2014 00:02:42 +0100 Received: (from ydroneaud@localhost) by localhost.localdomain (8.14.8/8.14.8/Submit) id sAHN2aGc008177; Tue, 18 Nov 2014 00:02:36 +0100 From: Yann Droneaud To: Will Deacon , Catalin Marinas Subject: [PATCH] arm64/mm: Remove hack in mmap randomize layout Date: Tue, 18 Nov 2014 00:02:19 +0100 Message-Id: <1416265339-8138-1-git-send-email-ydroneaud@opteya.com> X-Mailer: git-send-email 1.9.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141117_150327_041626_16B8618D X-CRM114-Status: GOOD ( 12.88 ) X-Spam-Score: 0.0 (/) Cc: Yann Droneaud , Arnd Bergmann , Nicolas Pitre , Tony Lindgren , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Santosh Shilimkar , Anton Blanchard , Dan McGee , Olof Johansson , "David S. Miller" , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since commit 8a0a9bd4db63 ('random: make get_random_int() more random'), get_random_int() returns a random value for each call, so comment and hack introduced in mmap_rnd() as part of commit 1d18c47c735e ('arm64: MMU fault handling and page table management') are incorrects. Commit 1d18c47c735e seems to use the same hack introduced by commit a5adc91a4b44 ('powerpc: Ensure random space between stack and mmaps'), latter copied in commit 5a0efea09f42 ('sparc64: Sharpen address space randomization calculations.'). But both architectures were cleaned up as part of commit fa8cbaaf5a68 ('powerpc+sparc64/mm: Remove hack in mmap randomize layout') as hack is no more needed since commit 8a0a9bd4db63. So the present patch removes the comment and the hack around get_random_int() on AArch64's mmap_rnd(). Cc: Dan McGee Cc: David S. Miller Cc: Anton Blanchard Cc: Benjamin Herrenschmidt Fixes: 1d18c47c735e ('arm64: MMU fault handling and page table management') Signed-off-by: Yann Droneaud --- arch/arm64/mm/mmap.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c index 1d73662f00ff..54922d1275b8 100644 --- a/arch/arm64/mm/mmap.c +++ b/arch/arm64/mm/mmap.c @@ -47,22 +47,14 @@ static 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; if (current->flags & PF_RANDOMIZE) - rnd = (long)get_random_int() & (STACK_RND_MASK >> 1); + rnd = (long)get_random_int() & STACK_RND_MASK; - return rnd << (PAGE_SHIFT + 1); + return rnd << PAGE_SHIFT; } static unsigned long mmap_base(void)