Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4279006ybi; Mon, 29 Jul 2019 23:04:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJtH4fbl78VPraPDaTS8uww1v2QizV/7/dnVP8iRm/LQ4V34kPLzAgPgG9WvRX2TRTC11n X-Received: by 2002:a63:1765:: with SMTP id 37mr38918021pgx.447.1564466670404; Mon, 29 Jul 2019 23:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564466670; cv=none; d=google.com; s=arc-20160816; b=E154yMmoBrshvlsSlcU89uHVpOAU85iXvI+FXV5dsDWhkkWhvnWLApPjP4huH4pQPg kpwW51DOzzLVGh7SUR07IWArs8Ko+qFTskDOkJRviEVvz4DbvcMToVrMuU1kqeXp8nO8 ZdiGaw4wI7rBjOHXqRd8PwagDtnd/zkMduaSWmBsBEPK4E1Kk6JhkbWgvPxCzaMPMAsW UtRM9XG5mIShodq1oxz8GoE0B+iyUydqVXRd4/sQW70bucsM0qIJalQodoCU1gyEl4Tv pIDu8B8KneFDiJfIp/pO+h1gYM+8zIOJrENrGELhD2fsd8SrlQ7djIcbG+NwndnGkGMv 5Fng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PQ9i7jzea9mGKNH8KcMLWsVLtL6mR1QxNOrNNbBorkI=; b=uoECA8HkuM0BB7ts9hXlz+TCLH8n16Tsq96I/9bor3Q00YjsNZCYzPUjL/9Jm3PvAN JWlAxRZjmye7I6x4AoHmoFKjmUfVtTomWKeaqbn4XANTXbxXb8Fg9SqkP/IewPTxgEAy mnIBU8THqQAM+CVfe5ybfIaEvM80FTRoBDL1dh/3ps5TetaUiABtFT2kpZKNonfbOR2T xvZG6AqJrg3JbA9Q1Vw5HRnlkoOW20/aYTObMVORTLrO9KOHYQr7rTo6BOh+RNVBJsH9 CdiZlEN9UNWvt16Hb4JaNDyoF0aY1V4SAIesgmqv+yrffhCPeUimK94EwMk6+HNziFns YBtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 78si27992978pfz.268.2019.07.29.23.04.15; Mon, 29 Jul 2019 23:04:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727165AbfG3GD2 (ORCPT + 99 others); Tue, 30 Jul 2019 02:03:28 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:46003 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfG3GD1 (ORCPT ); Tue, 30 Jul 2019 02:03:27 -0400 X-Originating-IP: 79.86.19.127 Received: from alex.numericable.fr (127.19.86.79.rev.sfr.net [79.86.19.127]) (Authenticated sender: alex@ghiti.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 0BBC320006; Tue, 30 Jul 2019 06:03:21 +0000 (UTC) From: Alexandre Ghiti To: Andrew Morton Cc: Luis Chamberlain , Christoph Hellwig , Russell King , Catalin Marinas , Will Deacon , Ralf Baechle , Paul Burton , James Hogan , Palmer Dabbelt , Albert Ou , Alexander Viro , Kees Cook , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti Subject: [PATCH v5 11/14] mips: Adjust brk randomization offset to fit generic version Date: Tue, 30 Jul 2019 01:51:10 -0400 Message-Id: <20190730055113.23635-12-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190730055113.23635-1-alex@ghiti.fr> References: <20190730055113.23635-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit simply bumps up to 32MB and 1GB the random offset of brk, compared to 8MB and 256MB, for 32bit and 64bit respectively. Suggested-by: Kees Cook Signed-off-by: Alexandre Ghiti Acked-by: Paul Burton Reviewed-by: Kees Cook Reviewed-by: Luis Chamberlain --- arch/mips/mm/mmap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c index a7e84b2e71d7..ff6ab87e9c56 100644 --- a/arch/mips/mm/mmap.c +++ b/arch/mips/mm/mmap.c @@ -16,6 +16,7 @@ #include #include #include +#include unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */ EXPORT_SYMBOL(shm_align_mask); @@ -189,11 +190,11 @@ static inline unsigned long brk_rnd(void) unsigned long rnd = get_random_long(); rnd = rnd << PAGE_SHIFT; - /* 8MB for 32bit, 256MB for 64bit */ + /* 32MB for 32bit, 1GB for 64bit */ if (TASK_IS_32BIT_ADDR) - rnd = rnd & 0x7ffffful; + rnd = rnd & (SZ_32M - 1); else - rnd = rnd & 0xffffffful; + rnd = rnd & (SZ_1G - 1); return rnd; } -- 2.20.1