Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6792149ybi; Wed, 29 May 2019 13:15:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOJfoINIq9rGfxyzCUzbt6O1wNgNl5kojEBfTNC6xsuW00UQCTVgXc4o9unGsK4aOxnR4N X-Received: by 2002:a62:75c6:: with SMTP id q189mr149482255pfc.98.1559160945600; Wed, 29 May 2019 13:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559160945; cv=none; d=google.com; s=arc-20160816; b=joq2oywD8shjY9/N60bZlOl/FrF7k48zCPCMl8+4dBJ2hHv+oGgXNxwvAW5Y3myr58 W9ZNit/kaH6Bo2j3/lUIPy2td16q5LdbPyT9tZS1kBH41u2/05aCMA7Ud+C3N071zB3C 05PzuJPB5hH/9ceLkCAxSrpIa83IkZfBxIBATpUbZuueqQOhJy5hxBZsRXt0Wau5uQZO eFLG6KFlXx8loCgCsyixo6MOC4PYanZQpuEruB6TFDaOWxpPcOa88nIMQ73xP7cbY1Ey fBCbDcjtOoJeS+9TFVRlgPHoJJB2kx2S7DQuwNt7Ib3iDRNdlCDgbQsLfu54S5iaV9Va DFJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=PGcw43rEtHfebZ1ykAg+O3oB9Ib7l867UUY+4n/dk/Q=; b=Uy0KrAnnzugv2MXijPSmeN2VfmfQDu/VHxZwwkNn0D8zmcP9faHaSZFxTQg174UYTe fACOvkOWwpbZyxKg/QA5QkmjARQW31ojy8feCOxaV+wmRAuMEk4+77rF/pVbW1MnZbfZ gxdGTdyjAThfPttnn5y0iZvlZGG7xHirdRt6uMpjy3JNtjLJarLqAzz+ht6YqpXdBGOS 6wklhxbwHIzBYUMmVcMwtVbFmaEJZrfjW39a1QnTL5LNIjRUlNjnB+0fn0LscaFJuHCL MqGn21Q/1nJ0knG/RG/z4q5KnIu1Jmj1nuPxbA1MappIfA6lMOoOi1N7YX4mLLtgzL2v +lbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="mD+XA/C1"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t189si813199pgc.530.2019.05.29.13.15.28; Wed, 29 May 2019 13:15:45 -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=@chromium.org header.s=google header.b="mD+XA/C1"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbfE2UMN (ORCPT + 99 others); Wed, 29 May 2019 16:12:13 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37027 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726311AbfE2UMN (ORCPT ); Wed, 29 May 2019 16:12:13 -0400 Received: by mail-pf1-f193.google.com with SMTP id a23so2353197pff.4 for ; Wed, 29 May 2019 13:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PGcw43rEtHfebZ1ykAg+O3oB9Ib7l867UUY+4n/dk/Q=; b=mD+XA/C1RPTuYpF3bAQXZIvQOGFykfuFTGv2T4SJe7rylVcI8w0NDLRy0IsBLJ66C4 yVcYvfhvVtwxJaG6tBzpFRpEcG+JM4ZK+8yr+Vmhnc0lkQZ9h7mnNWkXgsjQ03iN9T3Y xn9BTzPrq4mJgfWOD9cwdHXpGjo9qYZ06UsdU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PGcw43rEtHfebZ1ykAg+O3oB9Ib7l867UUY+4n/dk/Q=; b=DlIztW/YtrpBq43ZXSP5AzCsN/9cobZ3Gm9DZ9GC9TsU1vjKGe+HAUaFRAV7E0s1pd jHnXXwgF6FGAXG1QL/N00KlcYzyz+4YUpTr2yCEN2AEX//cwJnEzAll6X1O5jMFRWNvt vYTgyP8aDTbzP0Dng6xCNir+e6DPuIS9nuVWvIlQtb1LYnzOfGkocF+r2fR9XjW+KP4s F6CRQ0ecGq88X1eX5csqKpInPgUn4J3dKxIWzoQcrmRrOQhLoWvREEgJ1qiHf70fqlp3 h0Fskaf5veMAGJ5j42WpvX23tpdZHdMq79RtFxCsSZ2XTStO/RAVh8rpaEwBnHc7Cl4F F6xQ== X-Gm-Message-State: APjAAAXd3z1ewpi5uO1mkbG1yQ4DFjOxiB3hGbiTGgpWAjC7xaI6PR5W MZ0WEOzexkhJI5ruH3RoC/zPeg== X-Received: by 2002:a63:f551:: with SMTP id e17mr11828943pgk.329.1559160732491; Wed, 29 May 2019 13:12:12 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j2sm494584pfb.157.2019.05.29.13.12.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 13:12:11 -0700 (PDT) Date: Wed, 29 May 2019 13:12:10 -0700 From: Kees Cook To: Alexandre Ghiti Cc: Andrew Morton , Christoph Hellwig , Russell King , Catalin Marinas , Will Deacon , Ralf Baechle , Paul Burton , James Hogan , Palmer Dabbelt , Albert Ou , Alexander Viro , Luis Chamberlain , 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 Subject: Re: [PATCH v4 11/14] mips: Adjust brk randomization offset to fit generic version Message-ID: <201905291311.7E88A71@keescook> References: <20190526134746.9315-1-alex@ghiti.fr> <20190526134746.9315-12-alex@ghiti.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190526134746.9315-12-alex@ghiti.fr> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 26, 2019 at 09:47:43AM -0400, 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 -Kees > --- > 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 ffbe69f3a7d9..c052565b76fb 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; > } > -- > 2.20.1 > -- Kees Cook