Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp208080yba; Wed, 17 Apr 2019 23:10:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeoHX1o7R2crNPIgrLciAgMBE9iknXh9a59PoXDaZmgFYQz341Ac6S2Z1qOx3EJYTJiwQs X-Received: by 2002:a63:f449:: with SMTP id p9mr3940926pgk.427.1555567836403; Wed, 17 Apr 2019 23:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555567836; cv=none; d=google.com; s=arc-20160816; b=JbDSny+vYNiwvPV+D8fYTbVDeRXKoN9Ck1PnkrEbJX/L2GnjDlgLdwTj15xrFssDIe KfDyV5e4jh8y1voL4MtMtkunMEKbHy+Y2IH1OYeH0hv7eiOCopA6ni/yhZElNiz/AtZH b3E8dJH+DM3XuZTWgqPYsWrQrYZdaZ1Z3St34X2dR9uXwAKPEIxjJV8UQsFnNaK6ebLg ttv4COI0AGSP2tFomR8aBpm7j0pSYLAc5q3/P8iM5eNLD+CcLrS6CLBajMSpWmhMDUv6 qbHtDxwxb5dvrD0pY6yhUWTzh+02XWef33cQ/FUGSBfX9RqRgHp6XevWyippdKgBo0Y/ AL5g== 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=3YxIuVKrhGADmewzu9OJtP8RmCUzuapD7GRBk6NNZsw=; b=XItQMenWPvXW2x9dwr5Qi+Vhr0jYXaAzHRGB5TptLtQ9Y+Vc9aJXWbmFhaJWIoEaBF f1/boWHuMNggTR/1CwjCtXr0Xyzvhcb093oThiYn6596yMqgSv2xW1vQz/c+82LAnMNp 10QsUmAYgfc+oNT3HqLqmCVkJB0o96fpF/RJR9sDz2efrD3SkVQQ6pqIZV0R9+dtbvEs xX86gE4CeskwdBMse2TYWfD6uTLJKeBJw9Mi21bWBR789GN3BwYc7RvobiHsa92CGFYs SoakGn8WZUH5iv21Bq88AaXkQ/hbVBAthPqh5mle/BhmQ3FDoqRrop0JobrU8PhZuodA HjMw== 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 j9si1242617plb.233.2019.04.17.23.10.21; Wed, 17 Apr 2019 23:10:36 -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 S1733192AbfDRGIJ (ORCPT + 99 others); Thu, 18 Apr 2019 02:08:09 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:37055 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbfDRGIJ (ORCPT ); Thu, 18 Apr 2019 02:08:09 -0400 X-Originating-IP: 79.86.19.127 Received: from [192.168.0.11] (127.19.86.79.rev.sfr.net [79.86.19.127]) (Authenticated sender: alex@ghiti.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id D89BD20008; Thu, 18 Apr 2019 06:08:02 +0000 (UTC) Subject: Re: [PATCH v3 09/11] mips: Use STACK_TOP when computing mmap base address To: Kees Cook 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 , LKML , linux-arm-kernel , linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, "linux-fsdevel@vger.kernel.org" , Linux-MM References: <20190417052247.17809-1-alex@ghiti.fr> <20190417052247.17809-10-alex@ghiti.fr> From: Alex Ghiti Message-ID: <16ed1829-a7ad-76b9-2929-9eb14406da00@ghiti.fr> Date: Thu, 18 Apr 2019 02:08:02 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: sv-FI Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/18/19 1:31 AM, Kees Cook wrote: > 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 Thanks ! > > -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 >> >