Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp80670ybl; Fri, 9 Aug 2019 02:50:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjfLlcokbmxnzCH8VNbipJTPE95OGU1h7JFqZosaPCpiqVuXSd8cA6JRyTVIX8Ys5SkC4I X-Received: by 2002:aa7:8705:: with SMTP id b5mr21379169pfo.27.1565344259910; Fri, 09 Aug 2019 02:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565344259; cv=none; d=google.com; s=arc-20160816; b=BTcyedf0yWZErKp04/TZQnQAqgQ+iqQLrbEc8Dm68gdHYTAOIsJ1AfhCfw1sZ5HmX7 JeEsQyzplZumoqdRNuOsfCBQFFhsyjlbBtFb5WBQqHMxfcsapxMRrZiIZ3KvR/6MQGZJ R77YGeWvQNLTOybD0jkkR+p3kh/uU85bGsM6Optf7+JMb97dKFkBQJyYclJzWwLLtoiL o4g1HxjvuX8NphFz+p05lcXUL1FCvstJ3diCm+vuwTAW6dtyCKEWoMgweJoQ/oLCNB/9 aXKA3JSzCWcoqN/WrEoNvCRGlUz7A7J+W1I4v5dJVimqgw3u3xDCIN1dL6I9yV5NpmWg K3QA== 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=u+yMsGsz3qYZrzgBsVFmvJg3hEL2voIKGyVKr14Ljqc=; b=Sgjr9Kz3FtBcIR28KpTOkskBh5z6VfiNWubJCarott4Zx6onBSHQYI5IncDLI3Dp/e BlREatSrVho6oolaT4cIFqvAckJbTT+JHFKgrADYf3/+jQApQzVkutV45aPUOkqrrTat zpKyegeApxC9z6OT7KRyQfCZcs6oMjQdCZ5T/QZLeRynfE95+9uOQmRM0kiT3mfCLZKv 4kU2B86tQEi4ViBhTnnpjgb2L5PJ1Vwi2R1+J/5y4zAj6ots9pCny05eQCzXoj7DlWPM wFodr8RfTHzsbfmEAJ0w6Okzg+TOaMKpcW7agEi0AR+sQ5HKU3u7cU2Zbe1eR43QfLT5 5wjw== 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 m10si4034812pjl.77.2019.08.09.02.50.43; Fri, 09 Aug 2019 02:50:59 -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 S2406211AbfHIJp5 (ORCPT + 99 others); Fri, 9 Aug 2019 05:45:57 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:35101 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406138AbfHIJp4 (ORCPT ); Fri, 9 Aug 2019 05:45:56 -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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 732B46000D; Fri, 9 Aug 2019 09:45:51 +0000 (UTC) Subject: Re: [PATCH v6 11/14] mips: Adjust brk randomization offset to fit generic version To: Sergei Shtylyov , Andrew Morton Cc: Albert Ou , Kees Cook , linux-mm@kvack.org, Catalin Marinas , Palmer Dabbelt , Will Deacon , Russell King , Ralf Baechle , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Luis Chamberlain , Paul Burton , Paul Walmsley , James Hogan , linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, Christoph Hellwig , linux-arm-kernel@lists.infradead.org, Alexander Viro References: <20190808061756.19712-1-alex@ghiti.fr> <20190808061756.19712-12-alex@ghiti.fr> <68ec5cf6-6ba3-68ab-aa01-668b701c642f@cogentembedded.com> From: Alexandre Ghiti Message-ID: <7b7e256d-5106-3022-9ded-0af4193b6b8b@ghiti.fr> Date: Fri, 9 Aug 2019 11:45:51 +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: <68ec5cf6-6ba3-68ab-aa01-668b701c642f@cogentembedded.com> 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 8/8/19 11:19 AM, Sergei Shtylyov wrote: > Hello! > > On 08.08.2019 9:17, 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 >> 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 > [...] >> @@ -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); > >    Why not make these 'rnd &= SZ_* - 1', while at it anyways? You're right, I could have. Again, this code gets removed afterwards, so I think it's ok to leave it as is. Anyway, thanks for your remarks Sergei ! Alex > > [...] > > MBR, Sergei > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv