Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6022501ybn; Sun, 29 Sep 2019 10:38:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxIXhwhhy7gCTsofNf8qPz75jM8u8HoZBtvYs9K/RxIRIqBt02EGvxwDG7DB67U9yrZ+/+ X-Received: by 2002:a50:f78a:: with SMTP id h10mr15708419edn.161.1569778698722; Sun, 29 Sep 2019 10:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569778698; cv=none; d=google.com; s=arc-20160816; b=emewjHmlICzSSvays2eKGy8IJH4GQ8oQGif404UTitIngAOgSzeaMQJJJtZV5fjqBn 0HxbNUIED5h9MVfyjAM+fw3ydaM6qbkp0iDShFI0JegXFq/royhZpC83e7Dxgpa0ESEo 6ud+gusEqdreOhkRkPR6RcL3l5gsDNpeQUaOkQ0eS8Yr4kEWKEQec0GQ/gDrnES4nHQm zswXNX4Ad7NO1IlhoVBlV+EQsjgyyyzcUlSKrQ8xF0q1Bt7VMTcYgFTjuRYkK1uRg4IL 4AVXptZh5yDt3caj1oxgWMejlD7gWJYgSZQMUOCfZV2oz2Ey84OEWeTuwJ8gWQUEmPep +QQw== 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 :dkim-signature; bh=jHf/x1g9tGrr+1WSoTQ2URx4UkXSDqrDndKpGNK4kVM=; b=Vsf/Udg5TLlNeTYiFfyYNcZsMoIpB1CZOYDLizE1uthdeMlAn3kXSbLtNAE2TnyqRG wM859dHAaPl4KUPhXSyrM0x+2+qahRgt5+QssLnG2hd8Bb4fUogEfWTIMK4/Prgrs4Eo JKKgZ7hJ/NAmFs0ch1IVyQjBK+SG3G72erwrJz100TabO4vfK6/WvaouxtfkQQlmdenO k+o71hoHBeVmJnCKpld4oGzzx6nkuuUlU27B/OzlA/t3MmZL5ezT3xw9wS68TcyYmJ9z zyEZ1Zv+7uJezpn7gvDXlu/fwwF5Xro3+eFm7yB6sdbAxphR2ilFH7pRbo1MP7oNWwcy pkWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DGTXIzri; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b50si5697627ede.28.2019.09.29.10.37.54; Sun, 29 Sep 2019 10:38:18 -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=@kernel.org header.s=default header.b=DGTXIzri; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730596AbfI2Rfh (ORCPT + 99 others); Sun, 29 Sep 2019 13:35:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:47704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730605AbfI2Rfd (ORCPT ); Sun, 29 Sep 2019 13:35:33 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DDE3F21928; Sun, 29 Sep 2019 17:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569778532; bh=Rq5KCnNb5DcsX1r+Iur5At0kw9Uc65vXdmpWwLR0yhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DGTXIzriZBYQ7lCcUwsiB5/dU0nVa3xwuPc+g2mpF/y6Up4MksFBmFMrECG68C4o9 Ii8DLuAFdmWNRK97QRUV1Db41H+3jyvwVKzdvEXGomjq309DZQkVhzyK1Hd1cdA2Pj JLSpYGliprzbGHUct+LC1vLh8plAh6Tyt11pZ/xQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexandre Ghiti , Kees Cook , Luis Chamberlain , Albert Ou , Alexander Viro , Catalin Marinas , Christoph Hellwig , Christoph Hellwig , James Hogan , Palmer Dabbelt , Paul Burton , Ralf Baechle , Russell King , Will Deacon , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL 4.19 33/33] arm: use STACK_TOP when computing mmap base address Date: Sun, 29 Sep 2019 13:34:21 -0400 Message-Id: <20190929173424.9361-33-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190929173424.9361-1-sashal@kernel.org> References: <20190929173424.9361-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandre Ghiti [ Upstream commit 86e568e9c0525fc40e76d827212d5e9721cf7504 ] mmap base address must be computed wrt stack top address, using TASK_SIZE is wrong since STACK_TOP and TASK_SIZE are not equivalent. Link: http://lkml.kernel.org/r/20190730055113.23635-8-alex@ghiti.fr Signed-off-by: Alexandre Ghiti Acked-by: Kees Cook Reviewed-by: Luis Chamberlain Cc: Albert Ou Cc: Alexander Viro Cc: Catalin Marinas Cc: Christoph Hellwig Cc: Christoph Hellwig Cc: James Hogan Cc: Palmer Dabbelt Cc: Paul Burton Cc: Ralf Baechle Cc: Russell King Cc: Will Deacon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- 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 bff3d00bda5be..0b94b674aa91f 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