Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4278344ybi; Mon, 29 Jul 2019 23:03:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgF5Rc1EVk+Hx5k19HPBLZCUn01GZbO1dSsGwXIL+ZgJkLTS9fQTbuFJ4dfoTc/SjrmcIe X-Received: by 2002:a63:c751:: with SMTP id v17mr92687217pgg.264.1564466633905; Mon, 29 Jul 2019 23:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564466633; cv=none; d=google.com; s=arc-20160816; b=T8k8NCTWdGSBuWz/5A01011DL3va8RuRcROtMcjxW4RGNkTdu14GdmT6UEqxDfYLgq mth/A/L5CxbdyUSnuezR9qfasOSmtjJBcbPt/BPk9/ryEH3pwPp2hy/POXfCyCd+x1R9 X2SmrBXH2lPj0xDrfIjFC0K7atpCMCJh63DKu0n0V12ktEo8BAIVSqxdfXwGVIguLxd8 1UiiykJKz/1X1AU1l0SF7Sy5i7s7iBmYfJBfMoYaw8N3fBS9X7mh0QywGJL1aVJz/O42 ADceJnFG1HjH6pqHA+BkzAYteRUT8qQ4nxMkGZLdooSdyjiIt7vX6q3JhXqfg2j7Dd/m wOHQ== 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=WxmF21RRJdfH/w2FqV7+4BdBTMfTpzWDn1J10oDTzcaH5iYDE01NG0Ru32ZKezTQIv hfpCScibiDIWfG0n+6utGnk0QAeusyNEIg8h4nmOFhTonRHniYye08L7LbNRn+g1FS9m 8xt1ARcZcRUtf1DYp8rqOTarZZ8RZiiSi/pQ3mla3X1OhpggCpi0y4fLo8Qv+YRsUS8N Sux7Z4IFdHUykKKF9ofJ0WmyBYyxk/pnKSIw2RenmseOu2EjAw66yMXW20mOwJZmSRC1 3N5hJ5ur4jNp/lOczC5zxW1Xh/7VktxHdvDYKJ5KdLMN2pUlg+q3bpYcTm50Lj0Hrt1Z ol6Q== 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 z26si28469926pgl.562.2019.07.29.23.03.38; Mon, 29 Jul 2019 23:03:53 -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 S1726714AbfG3GCX (ORCPT + 99 others); Tue, 30 Jul 2019 02:02:23 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:38151 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfG3GCX (ORCPT ); Tue, 30 Jul 2019 02:02:23 -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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 925B41BF20E; Tue, 30 Jul 2019 06:02:17 +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 10/14] mips: Use STACK_TOP when computing mmap base address Date: Tue, 30 Jul 2019 01:51:09 -0400 Message-Id: <20190730055113.23635-11-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 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