Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6419450ybh; Wed, 7 Aug 2019 23:45:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxY02e9oeoRcYMuE6sHgzqGAMcq1tsvvWv9jA9N1iSoRtevVJxUMQxPIMMueS4o2Ge57q6W X-Received: by 2002:a62:d45d:: with SMTP id u29mr13681862pfl.135.1565246707325; Wed, 07 Aug 2019 23:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565246707; cv=none; d=google.com; s=arc-20160816; b=Zj3aDDYPw3KN7K1gFoDK8PnZFAgje85KtqohwjJrgcahCgBUICfNKY56EBgTiH3zSX 0A5AEGfaTCd/4IVJV6uaMtf5Op9HoC6gxbr+Hb832YVi8bAbjC7lp58PR5kFunyKSepi XHNiNQRcVLUnNCDzcUtUE6QSteSXhw4wuRZw05T2zQeSiINpVZDpcZfR4PUJZOfHlbdB aDbIR+0mz9IYvQBk7U+Tv2uRMQaOnf3mor18meXV9baOdCJJrCgx9/ckW4Cu3eg64PCG bMW6rmKr0l25dYZb/TZCKAKuM4Znp0p2Y/4MkuXi23zkw/WcZj952EXyCQ+8qmB3pvaF 6ZoQ== 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=CozSP8ClhxqYRnTVyauC5EuB32xQZZhYjVFYo6YFdyo=; b=WSa4DhGudSnd2li8oXCPJvBAmjg1XmefjA0HcldFXwFeE3DZCNgYeNeRZA2xWMc8Jt txfY5njasfger3zXVGbG3KmMbG7CChA9VVme2CPJSFs5FnMfjvfAdFPQRDxMKdp2oP1v XC3QGnBhu0jl4BBS4eJRFUAgjNoXbjYBuXMcb1M+8fVgENEG0MiZL8Xbk+s6ioxs7FRh EympV9kvaOVq41M7nyhMptubqwfXGihcgIuKzZZCRC2a8f2O8Jz27in3Dmh9b+/djFUB RU64hVtu+9yLXVHRNALHbJxtH2Y7gJ5QqKhKPn9eIqCWcykrneZMWDgYTVmG+vM4xGqb BHeg== 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 i188si51460643pfe.96.2019.08.07.23.44.52; Wed, 07 Aug 2019 23:45:07 -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 S1731274AbfHHG3D (ORCPT + 99 others); Thu, 8 Aug 2019 02:29:03 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:44947 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbfHHG3C (ORCPT ); Thu, 8 Aug 2019 02:29:02 -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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id A498660009; Thu, 8 Aug 2019 06:28:56 +0000 (UTC) From: Alexandre Ghiti To: Andrew Morton Cc: Paul Walmsley , 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 v6 10/14] mips: Use STACK_TOP when computing mmap base address Date: Thu, 8 Aug 2019 02:17:52 -0400 Message-Id: <20190808061756.19712-11-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190808061756.19712-1-alex@ghiti.fr> References: <20190808061756.19712-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 Acked-by: Paul Burton Reviewed-by: Luis Chamberlain --- 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 f5c778113384..a7e84b2e71d7 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