Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6576114ybh; Thu, 8 Aug 2019 02:21:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5Zmc0dAPyhrjr3CUEfcU1VsEenQwjh5Kp3hgxH7gMYr2aN0kFlaAHbvpI1lQPWQ3wALLY X-Received: by 2002:a17:902:d892:: with SMTP id b18mr11872507plz.165.1565256107280; Thu, 08 Aug 2019 02:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565256107; cv=none; d=google.com; s=arc-20160816; b=oK8hzyzHmu5d0GXlbjfnTfKRO6R4TTrwQKHuuVjtPLbBwl3cV7+Lus9XTYytIL9/0t YC3I08++1imKHR8ABFhs2BvMIBmpunpqQ84x/JGLs+qV8Iq1kz5SHHtogTNnYyhY+tc/ DM2b6Xv9IZ/C9C3n6lmREi6Q842/FBCkqfRcZY4B7eULOfQbR2bpdk7Q+5MCn7aDCRiP p+zRi2CMYAmgDZolBfq3WXHXpzPsqdAN5jT7U9HiwbtdMLCX6uZGxF1yHJOZSp/R9B0n r4V2xy2lPPY+xCapn4z3w1vQ7uFSg+pTJDfTJ1ceFo52vRgiJyAhzA+4ufcjGvYfMZ+U ykiA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=OCitiiIQARt2srQdTEp8HHKk2MswJS9hy+qm/HN3L5Q=; b=m7u3SCt7Wjy1U+C7BAHuBkp1ibzIQEH62IUbaD/ID8q/puZTieXmc3u6OlEBnsp8vq g418yeZ3+GLODwjBpciSOulKNqsXVmUx1UppM9Aol2NDgL1uE75APnkIPednvm/SH/0Q QwVOJpoRBM+OA7io+TSb5kGg1WMGFK3SELS0pJLPtiIlsvJqkcW/gA6rCHUYXIgVztQB JsJ9WgPsXrpQOPNigjvdJIcNWXrgrw71q9Mixbwuy9jbKdvoHZUuvY/7h+UPvP7Hp60+ Xhoja0Bj/kHRdzkDgQXjDd6yoSgKUb0wxiFSV/fT8/U+QlaETB69LHQrKtZ1sAy8/qBx zm5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=eGiX9Khh; 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 m127si52031987pgm.100.2019.08.08.02.21.30; Thu, 08 Aug 2019 02:21:47 -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; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=eGiX9Khh; 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 S1732167AbfHHJUM (ORCPT + 99 others); Thu, 8 Aug 2019 05:20:12 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:38824 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732035AbfHHJUL (ORCPT ); Thu, 8 Aug 2019 05:20:11 -0400 Received: by mail-lj1-f195.google.com with SMTP id r9so88192485ljg.5 for ; Thu, 08 Aug 2019 02:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=OCitiiIQARt2srQdTEp8HHKk2MswJS9hy+qm/HN3L5Q=; b=eGiX9Khh6PGwyt3vEDZS5i+7Ttn3dev6cKijGsAKu98PEo2SOHWYpChGzAR8G6rqiH jzgQRh6WatLMuo4AbNf4LAJr20oUT+cZdU/1CJnSqTguKc+Ybw4jmkdw0OadBReXodeF ebkbMHm8MDy0PwD/pEvqEAPbq07rO3qstGtOj2YxInvoyEp2nXA39FzVCr7+4l19jsYI 3s9hm6A/4KWKEqwiGw05Tvffpb0A0mj+ayAeSD24M3N45J6I7gHbT2TjJqBsaCxM8sqn rQPLBU1qx5jTkktaKHQLtADroikDfkHoEs6q4//nMMWQlm8Px3F2v3VdsnP0ZIgPpvGb 4l2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OCitiiIQARt2srQdTEp8HHKk2MswJS9hy+qm/HN3L5Q=; b=lWXJr/sqBxLT2UgfJpt/ON7s7voMiRc+s1lLc1lnrPf812HlZ0CehHdYlk8yKG2Haa FN8YQNLQDYlcSVu+3x8/MvHZ2/deexQ4m6UStlxgJxL3rQhNnG31dE6pmf48XPJNxBsp CwwaI6V8pSU5kCFzJ6gQfV1pTquvnStL3IyeccuPOFseIX8jmc9dwgdPerImJLmhfzFU 3bJ5uthrwUJgjJ2XyZyLei06huOjf9chrSVlknudTlKfhYe3Ai+6uNpgA5FrbqHxdsDw xiIT9XrXsYlcabJb+ZZkQ7JIdqrzTYy1op2T/Mh9pAiV7cFTbyF5qIw11UmG4SwFd4o5 YYrQ== X-Gm-Message-State: APjAAAVvrOPKP/bvIjusIiTeOJpZwQ5ZVZTLR9zcTd0ddib+TO57f6ct ygdPXavJl94YMxc/8AhIjealjQ== X-Received: by 2002:a2e:9685:: with SMTP id q5mr6063276lji.227.1565256009622; Thu, 08 Aug 2019 02:20:09 -0700 (PDT) Received: from ?IPv6:2a00:1fa0:8c7:ada9:25b2:24d8:3973:eb87? ([2a00:1fa0:8c7:ada9:25b2:24d8:3973:eb87]) by smtp.gmail.com with ESMTPSA id u27sm17024138lfn.87.2019.08.08.02.20.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Aug 2019 02:20:08 -0700 (PDT) Subject: Re: [PATCH v6 11/14] mips: Adjust brk randomization offset to fit generic version To: Alexandre Ghiti , 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 References: <20190808061756.19712-1-alex@ghiti.fr> <20190808061756.19712-12-alex@ghiti.fr> From: Sergei Shtylyov Message-ID: <68ec5cf6-6ba3-68ab-aa01-668b701c642f@cogentembedded.com> Date: Thu, 8 Aug 2019 12:19:56 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190808061756.19712-12-alex@ghiti.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? [...] MBR, Sergei