Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4276067ybi; Mon, 29 Jul 2019 23:01:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCKWnkyIIRUODTawSFVT2KD9LJdaE8hob6JUp3wdmzB+gWMe2Li0GcK8pa+eHEfZBrNHgs X-Received: by 2002:a17:90a:8985:: with SMTP id v5mr113809787pjn.136.1564466510898; Mon, 29 Jul 2019 23:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564466510; cv=none; d=google.com; s=arc-20160816; b=iizycFzA6FSMYErm9MSQoYVmCy89hSVo/Sk48+z4Cqditz3gJSnyX0BHjkM806vbhq xvSpGQozVL9Cz+WBPobSqrcXLaT8l43m+c4rIJKEkFs6+rNqZnVfVt6bbYD57jjmAHy4 71nNRHWB5wgu0Ggi92x9Fji2IorB3GECFuUVO9tv/Zh5Q0e/LiMTfuf1lv8zwFPf9nS5 9cuzbalE579GI1bl/KT0hWxqMNGIORzysJ8URoNlbchoPlIJixSua/+jFYA6aP6mR/Hu kXFogFzOwvHCZNaEyDs61yLG2mQnrpGRtN1xZA3w3RUZzVISCNTyHNHCyHfz5LCjqi+W 4RGQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WYZFBi/mDjw2AHO/7J+UsrC2CAAthlR5mqmiph32kXg=; b=ZEE7XuXkJl5FrgMnG9bZ+vO2qFnSCKu52sJWmIMrf3fMQLMEXlpx0Ud+Fbd+MH+NTO 6nxX/uugpLdU926zvqjEAAdgIHPA4kUyupkqF1+bhJSxmjtLpzjjpL2W9M06ArLgIF/r Z6hvEg3HaMjPuKRj/HQQNAWKz0W1A0vg9MjtYlzIILrQgeQWWQheSZHOZnZZpcBgqws7 fHPuQ2osgu5YQOla841pZnRuTT2RpPb/hRCAHUSRhpzWNB08YNlT48vavW4qHVG5hdNQ RriyyZ9r1SbkYsNWJqFSh49dfRYJiW2ni5aH2lOBfe6T2PZehXcbncOSm9EnGr1dZ/sK hHMg== 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 e2si27768318pgf.256.2019.07.29.23.01.36; Mon, 29 Jul 2019 23:01:50 -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 S1727165AbfG3F7K (ORCPT + 99 others); Tue, 30 Jul 2019 01:59:10 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:50165 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfG3F7J (ORCPT ); Tue, 30 Jul 2019 01:59:09 -0400 X-Originating-IP: 79.86.19.127 Received: from alex.numericable.fr (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 E90EC240007; Tue, 30 Jul 2019 05:59:02 +0000 (UTC) From: Alexandre Ghiti To: Andrew Morton Cc: 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, Alexandre Ghiti Subject: [PATCH v5 07/14] arm: Use STACK_TOP when computing mmap base address Date: Tue, 30 Jul 2019 01:51:06 -0400 Message-Id: <20190730055113.23635-8-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190730055113.23635-1-alex@ghiti.fr> References: <20190730055113.23635-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Luis Chamberlain --- 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) #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