Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9164845ybi; Tue, 23 Jul 2019 23:08:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4BoDcZPsP4ETv10D+mTkLhsfU9/V/sKOAQ1ETl7NaL+y10pEUZ8Yda6FFcfkDpPhQgcB9 X-Received: by 2002:a17:90a:376f:: with SMTP id u102mr86707542pjb.5.1563948493986; Tue, 23 Jul 2019 23:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563948493; cv=none; d=google.com; s=arc-20160816; b=PqE6c6u8Cc6q6Y5S54ntaBXnpWSOr6ZDM7WiJv3iUu3W7DyRhtMNV9kRHkxggIU8UJ pslawebQ7o+uJZlO3AxO9aeCIcb0FsyZ2THx2WccS0L3SXMnzCKHDke5/XgUjp1HO3qv obh4EAipHJ4z5Cm8EFFldrCxVHgW5phFLg20AFeSfm6ww+hYXAKbBhwYXT57QCRL8woX iO4gmbZajDVC/wNIf53RC0rVF+J0267L/YkVbgJWP1asmg0DyG7M1oPInAi4l4PqvQVV mpHKrvJO7PMgPJiQYRdg9op4Wv3wWt60kPOzO1PRpFyRENAKfjk9v5SMaPE+plUUp4Mb 5W5w== 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=iEUnru/pgX+pWRywt03LhpHMFzmbntBrlVCKRjubFbE=; b=w10J+9c+HvFfRKjthtQAFcvapcHRe/tlgEDzx8V981739Fxql5NDnfi8TgXwltvwxe l9Ma/M1tMicus43AZcj1LURuM3+G7ElGYoPbKSLjtMJUkTHOpXc0GeRLz+FKvfKmPahV cNGUtajJUXCeoK541YmrsNOaDXzqhnmDDNy5xf2aJ8303wUsTVHagtj9hu7zCny1YKtQ HejP2V+ODI/Ro/bVzrDx/KqVS6rFZtO7sAk/yFlzV+f3iwKDBeLBwcFy0Oz4vum9n779 IG/qW0PbpX36BfXvNZ0cza4jSfpArWdRWIoxHIAwZglXzNsQJO72Y6H3DT6QdO8nTqs7 NHMw== 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 h9si13114565pgp.435.2019.07.23.23.07.59; Tue, 23 Jul 2019 23:08:13 -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 S1726635AbfGXGGp (ORCPT + 99 others); Wed, 24 Jul 2019 02:06:45 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:60469 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbfGXGGo (ORCPT ); Wed, 24 Jul 2019 02:06:44 -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 relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 45F331C0007; Wed, 24 Jul 2019 06:06:36 +0000 (UTC) From: Alexandre Ghiti To: Andrew Morton Cc: Christoph Hellwig , Russell King , Catalin Marinas , Will Deacon , Ralf Baechle , Paul Burton , James Hogan , Palmer Dabbelt , Albert Ou , Alexander Viro , Luis Chamberlain , 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 REBASE v4 07/14] arm: Use STACK_TOP when computing mmap base address Date: Wed, 24 Jul 2019 01:58:43 -0400 Message-Id: <20190724055850.6232-8-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190724055850.6232-1-alex@ghiti.fr> References: <20190724055850.6232-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 --- 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