Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11017773ybi; Thu, 25 Jul 2019 08:35:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzewuy+yUlH2znXr66xoFU1f+ZmrKEo96NFaLh6p1992pNOikYxhU26fp8KZPNI3617VI8 X-Received: by 2002:a17:90a:cf0d:: with SMTP id h13mr41566779pju.63.1564068929445; Thu, 25 Jul 2019 08:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564068929; cv=none; d=google.com; s=arc-20160816; b=dZi2rDM3R8tg0ijX7Ih/frVZdCmIIcXr2IGrruG/WcoIxOlh0cTuOohvrPMbvdzJxP ppI/xpWimFG3DEdF3cvtv2lu/dtjRAI9RRe1IM4bhoMZxUE2IKLaGOkeS2y+l872glzd 4gXlPZ5N0sxX5hGD3nazdlM3a6OP1URYfxF4U6ZcoOYpMmVxZE/Le8QBFVyQjUisC2o1 +p+fAVvOeVh1B7h315lSDF60v1uYxD4dYaPbqZnyQ2vhoajN8VG2e9AGSHgdvllRLAM8 42Olb8u/VA6tOIH2fjhGtIuDX/vQ1+vCekrAej5hTxLYm8G7PvCS9JiVA1sORy8nbLgk X7Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=51AIC3JPqwnkDKcGbRstueAsQKK3cIJET1xOLNapmvM=; b=Ky/QQGUtDqJYbA5py8gOofK4tQ+xgaFD6hjjOBW9t4UzwhnrXNc7KqPdlb5mf2r2Hx PqjEk9g9QhMOLvnhMVuMOvEgbL+quabW0Y20OmaqqTxXoJrnbWJ23iS2XkqZAWv2K7p7 Bzb8MPCumNWeD0LEhDPIPoLE6HYwsl6hP0OEzoRZ0Un9DDkc3L78YWf0zt88JWL/hf8v mzRsxKiub9hfYQTtbFFem5sUO8kDTUtNjjddPNB9thMXKdYuRFeqhAsH/VDGikC/mxgr ieGC7DaXD+K1uDVEufHHddiDzvBhUXVoSB2uaUWqPfz2KKQdqTI4L1ENrBAW7UxiHpgr TLCw== 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 u62si16539846pjb.3.2019.07.25.08.35.13; Thu, 25 Jul 2019 08:35:29 -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 S1729228AbfGYGWM (ORCPT + 99 others); Thu, 25 Jul 2019 02:22:12 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:39559 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725800AbfGYGWL (ORCPT ); Thu, 25 Jul 2019 02:22:11 -0400 X-Originating-IP: 81.250.144.103 Received: from [10.30.1.20] (lneuilly-657-1-5-103.w81-250.abo.wanadoo.fr [81.250.144.103]) (Authenticated sender: alex@ghiti.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 5DDD5E000E; Thu, 25 Jul 2019 06:22:06 +0000 (UTC) Subject: Re: [PATCH REBASE v4 11/14] mips: Adjust brk randomization offset to fit generic version To: Andrew Morton Cc: Albert Ou , Kees Cook , Catalin Marinas , Palmer Dabbelt , Will Deacon , Russell King , Ralf Baechle , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Paul Burton , Alexander Viro , James Hogan , linux-fsdevel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Christoph Hellwig , linux-arm-kernel@lists.infradead.org, Luis Chamberlain References: <20190724055850.6232-1-alex@ghiti.fr> <20190724055850.6232-12-alex@ghiti.fr> From: Alexandre Ghiti Message-ID: <1ba4061a-c026-3b9e-cd91-3ed3a26fce1b@ghiti.fr> Date: Thu, 25 Jul 2019 08:22:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190724055850.6232-12-alex@ghiti.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: fr Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/24/19 7:58 AM, Alexandre Ghiti wrote: > 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 > Reviewed-by: Kees Cook > --- > 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..faa5aa615389 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; > else > - rnd = rnd & 0xffffffful; > + rnd = rnd & SZ_1G; > > return rnd; > } Hi Andrew, I have just noticed that this patch is wrong, do you want me to send another version of the entire series or is the following diff enough ? This mistake gets fixed anyway in patch 13/14 when it gets merged with the generic version. Sorry about that, Thanks, Alex 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;  }