Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp181055yba; Wed, 17 Apr 2019 22:33:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLYRGYLOyIY67QPNGqI2YqC11bYbNfB5wF7iosSqO4QSDv4YZ5XftyWXoSW2+B5DYuAjIB X-Received: by 2002:aa7:8e04:: with SMTP id c4mr58454847pfr.48.1555565631829; Wed, 17 Apr 2019 22:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555565631; cv=none; d=google.com; s=arc-20160816; b=hiC2I0xTyt9ViXICWyY2kotbZgIuUWyEZU8vuxls+B407DjjIwp0PYndptW0drxUk0 kR1BCCMTXXLbvQuvEssrX2NmO5Z65DcROgZL/qdFXO6ayWYgfYr+Tt9cHaZ/ZgRiFxe2 vfE6GGEWZXaVFkh4IhRXAmXz301CkmRYJYdnu7HodmWeYv8iId7jo7E3LIWECZ6Mp00Z lCTr0zPRTHKMkWGZq+l7W0TFiXhhhrS3a1lLO5JadQdpYXLDcPzIzJtRorRN+Sw1rJ/y MLKIiHfkT7YJYUj2PUQUnA+xAo+kqNqhSiuGo/aw6Nfp3UfDFAljELEbuPKREKUkaraj NU5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=x/TP6sA5sajZCj+xhLCrRc8XOgk3i0sdPUEQY20nxic=; b=d14o4xgIPx17Huz184FeSLwjACuY+KXI/Ph9II6XX5BxNss3ZIkpxS3lHtXoOan7tm TyeZ1b2j8BYg851LxO14lI90fxxaC6TIYgPLfF1TyCYQ0vl1iO0vHa1LggNgBdjjbdPu p9luDgTyV8W1B0GsQT4TFaAUAUJ3/zIDPowCscdVHuftueDHdz6wY0FhIwzrspvoM+/W 1EX16HrBNqLgXHnipZfqvCMI6ByhvZp0TllQfv2RlZtTRC4DpabGIyxCT0FSQTCNhWeO LZIqhaSBEVbDYEQm9Oby0MHF718TaDaFMSfg+grPS85E3XSX3ID90eTmRLsrOJKO13JA I6xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EzI3iDp3; 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 b6si1105061plx.325.2019.04.17.22.33.36; Wed, 17 Apr 2019 22:33:51 -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=EzI3iDp3; 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 S2387414AbfDRFbW (ORCPT + 99 others); Thu, 18 Apr 2019 01:31:22 -0400 Received: from mail-vs1-f65.google.com ([209.85.217.65]:33806 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731806AbfDRFbV (ORCPT ); Thu, 18 Apr 2019 01:31:21 -0400 Received: by mail-vs1-f65.google.com with SMTP id t78so526004vsc.1 for ; Wed, 17 Apr 2019 22:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=x/TP6sA5sajZCj+xhLCrRc8XOgk3i0sdPUEQY20nxic=; b=EzI3iDp3/PwAWlzrGsEJt8pSHXmaq0t/LgPtPVDCMvm+jD1PtYJaid1ZV/xGYcmd5I lwY7VI0ze2TcOE31b8X8Debj5ZrSlCq5cQ8C17/vua658wrm2sWXYl5IeWCxo5rmKiWr /FetUT2kibkKsifqxGloTOoB5vk3HAZhnG57A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x/TP6sA5sajZCj+xhLCrRc8XOgk3i0sdPUEQY20nxic=; b=F484ZxW2hxNmQKEvB/rKGR+XCD4MEsvk3LrBq3tKGBeS2YAVpuQMiVPz64Pa6/FLR0 IUDv9Tl1JfQOBZoBDQcIuxncVkDmCUJga/Z2EBfihCY9nm3GuNm8QQsL/FwD0b3GdbmH CZ0iff2IfTU223Uy+MT6/E6qiokjuetA6hEFRYu99re0ar8yqZGg/6pcfupfMn/MJ6+c nznA3KQq3R268WnrjQCd0qRF/7DFKQ9EDzER2z93sseWb30C4gA4qGzIf+qZAjJ54uuQ nGA0mP1qsrH5nvUYEt34voKI+6iivU1vf/VLRSNJr8XhqXcKTYdCHXTuv1N+T8P2d3tw F2Ag== X-Gm-Message-State: APjAAAV6ETyhIvANzYrqXnSEbCind1wmgIQnPm0/vc6PsdLCNNRXuWyR o/wcpf56MkR+pvDJPCYFNG8oZfgFbFY= X-Received: by 2002:a05:6102:25a:: with SMTP id a26mr47581713vsq.187.1555565479884; Wed, 17 Apr 2019 22:31:19 -0700 (PDT) Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com. [209.85.217.48]) by smtp.gmail.com with ESMTPSA id q190sm445043vkd.50.2019.04.17.22.31.18 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 22:31:19 -0700 (PDT) Received: by mail-vs1-f48.google.com with SMTP id j184so495001vsd.11 for ; Wed, 17 Apr 2019 22:31:18 -0700 (PDT) X-Received: by 2002:a67:bc13:: with SMTP id t19mr2611825vsn.222.1555565478030; Wed, 17 Apr 2019 22:31:18 -0700 (PDT) MIME-Version: 1.0 References: <20190417052247.17809-1-alex@ghiti.fr> <20190417052247.17809-10-alex@ghiti.fr> In-Reply-To: <20190417052247.17809-10-alex@ghiti.fr> From: Kees Cook Date: Thu, 18 Apr 2019 00:31:06 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 09/11] mips: Use STACK_TOP when computing mmap base address 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 , Kees Cook , LKML , linux-arm-kernel , linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, "linux-fsdevel@vger.kernel.org" , Linux-MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 17, 2019 at 12:32 AM Alexandre Ghiti wrote: > > mmap base address must be computed wrt stack top address, using TASK_SIZE > is wrong since STACK_TOP and TASK_SIZE are not equivalent. > > Signed-off-by: Alexandre Ghiti Acked-by: Kees Cook -Kees > --- > arch/mips/mm/mmap.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c > index 3ff82c6f7e24..ffbe69f3a7d9 100644 > --- a/arch/mips/mm/mmap.c > +++ b/arch/mips/mm/mmap.c > @@ -22,7 +22,7 @@ EXPORT_SYMBOL(shm_align_mask); > > /* gap between mmap and stack */ > #define MIN_GAP (128*1024*1024UL) > -#define MAX_GAP ((TASK_SIZE)/6*5) > +#define MAX_GAP ((STACK_TOP)/6*5) > #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) > > static int mmap_is_legacy(struct rlimit *rlim_stack) > @@ -54,7 +54,7 @@ static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack) > else if (gap > MAX_GAP) > gap = MAX_GAP; > > - return PAGE_ALIGN(TASK_SIZE - gap - rnd); > + return PAGE_ALIGN(STACK_TOP - gap - rnd); > } > > #define COLOUR_ALIGN(addr, pgoff) \ > -- > 2.20.1 > -- Kees Cook