Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp203653yba; Wed, 17 Apr 2019 23:05:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwPloNiDrtbGcBq8oZvBgZNU/Zg24MFgXEtdADquG6Mf3RympsSDLTzdd4IjF2M3L9/nm5 X-Received: by 2002:a17:902:382:: with SMTP id d2mr32690429pld.253.1555567522306; Wed, 17 Apr 2019 23:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555567522; cv=none; d=google.com; s=arc-20160816; b=SyVoHuU4e4k7FOpCubhyqpIDx+5IHkqducbmiqy52n6te+UEc+iX0zIloX6mWdbbFZ ykMnXR2ZDGF1AY9P6y4RlZEWaPPtpl4CI7m2V8cIVR4iKd0OUt6gbIUHas8URM6fqJkV pzAxjFa4qNihgo6OT02xi+pRIYsDOht49cCt7LuO4vyZpce01iiG8BtUjB/ds29vQSoK LBiGbKu78BIF2CdoX25Eh5QrSdEui4tcqRrYegpwIC5ZaebtuVgzeuA0f3pWLREQA7aQ do4U8TPtEVDCRrzY4gfO1MFTeYVRyLXVHWeWO1QsQifjpC/nBeiSUnYSoqysqoYyt9Bl t9Zw== 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=NMZGZi7E/k1uxDFQhdlQAQLAcvZsm/HUaZEipShSxfo=; b=vfxhePIhLWz+BXFhKpvZZuItC/gIsttoxhr4Z8cEQLkVSQ1+m4z92eGiKuWwhJgMO6 iKg7qgFGkNVlAN6/uHaHDO/gcNyT9jpnMicJDgEK1IehTtTffsb0dEoKOYRIpLOIaoWo 6JZEPJiRIUG0Y63ulPOtJ7UMSC+v1kvNfg8fCi/gO4Wv56qOIGeLAP0sitOWgUy9Rqm7 LqVf3OEzq8hPR4JkDOKVO2EZDmwv1W4K+Gc1ywFLKdbFPGq6LZJzEzQibcXmFCd8acN+ fMg/3j5IwHQrFr9WyTP5Jan1WRB4escHZLI83MWB18JfRAusKN5t3BVdG83Maeqq+aDz c3zw== 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 s10si1195738plr.272.2019.04.17.23.05.06; Wed, 17 Apr 2019 23:05:22 -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 S1733067AbfDRGER (ORCPT + 99 others); Thu, 18 Apr 2019 02:04:17 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:44073 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbfDRGEQ (ORCPT ); Thu, 18 Apr 2019 02:04:16 -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 relay1-d.mail.gandi.net (Postfix) with ESMTPSA id DC0F4240004; Thu, 18 Apr 2019 06:04:08 +0000 (UTC) Subject: Re: [PATCH v3 06/11] arm: 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-7-alex@ghiti.fr> From: Alex Ghiti Message-ID: <9fdc1de9-8552-da1b-7d05-0596969ddad2@ghiti.fr> Date: Thu, 18 Apr 2019 02:04:08 -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:27 AM, Kees Cook wrote: > On Wed, Apr 17, 2019 at 12:29 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 >> --- >> arch/arm/mm/mmap.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c >> index bff3d00bda5b..0b94b674aa91 100644 >> --- a/arch/arm/mm/mmap.c >> +++ b/arch/arm/mm/mmap.c >> @@ -19,7 +19,7 @@ >> >> /* 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) > Parens around STACK_TOP aren't needed, but you'll be removing it > entirely, so I can't complain. ;) > >> #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) >> >> static int mmap_is_legacy(struct rlimit *rlim_stack) >> @@ -51,7 +51,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); >> } >> >> /* >> -- >> 2.20.1 >> > Acked-by: Kees Cook Thanks ! >