Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6420821ybh; Wed, 7 Aug 2019 23:46:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2z/B7m4R8IOt0GuftM7QLsbJFO/hJ95/3C2ZG0zFJpsvjKFiSpMlYh/vnSh8YNJxgy7ww X-Received: by 2002:a17:902:9a06:: with SMTP id v6mr11736134plp.71.1565246798426; Wed, 07 Aug 2019 23:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565246798; cv=none; d=google.com; s=arc-20160816; b=nGQrddlkLNHSFqRZmjPIhUgVht+A7Mw5TX0TDff7cS0uHhS0bH0oTMSDQ2k0oEGIQS RvnbPzbyfwBkZwpaK6S4VB22eQ+hLcfMTBxxP+qnZ6QmzYqqa1stzA6K+bnrd5vwPfdp tQOLrJbAL7I8iFk4CFWA9ChYRcenM6utkj3E+96AsCqB07hBzwNsB3d6lBNRFi1Lsx55 T2EK7c9/HOMPEUYgM0TUB0HHuu6vfNTOMR9TuwgLXUp7ZJApqN6krraW6ckAM2NmPTfC lIblrEHVfLcTk6xfnVPuo4UQi/987sn/fnVPGGvMULVgqNRWv2C793rX/IUv6nZ4bf7Q K5tg== 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=nUau4+HRRQY0d13YyHNyduFUEo7qNvWis9nkkDDr/Ev5DnjKJCpaGNbaratFjDTpeB w3B1Jmg8cK5XzeJ5Q/I63ZSZQKqkPQyv0HNgIt2nmKeOMdhrQkOkFu/BG52lOYM2prZS KgdDQgcakULL1JeGz9zhiJ3k5k9OBfA9MuYc4f6bLs7K+I1aE+Q6hfHPwL5pxQ1tiVvp CKMmuIDJ9DoKKluqTTR3Y4XDKI9Z6iwbnCqpBEX8jDjPSG6mDPnNIZMfla5yyuw3f12M iv2u2P2C9chAQ/sfeA4ktntp7pCWKEYtok4bVJXaUQH5nXUG5+vRH2L9qa7WD8Msh8mg gF6Q== 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 j1si53408291pgb.482.2019.08.07.23.46.23; Wed, 07 Aug 2019 23:46:38 -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 S1731346AbfHHGaJ (ORCPT + 99 others); Thu, 8 Aug 2019 02:30:09 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:44545 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbfHHGaJ (ORCPT ); Thu, 8 Aug 2019 02:30:09 -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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 42BAFE000B; Thu, 8 Aug 2019 06:30:01 +0000 (UTC) From: Alexandre Ghiti To: Andrew Morton Cc: Paul Walmsley , 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 v6 11/14] mips: Adjust brk randomization offset to fit generic version Date: Thu, 8 Aug 2019 02:17:53 -0400 Message-Id: <20190808061756.19712-12-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190808061756.19712-1-alex@ghiti.fr> References: <20190808061756.19712-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