Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2739579ybi; Sun, 26 May 2019 07:01:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXBf9Guwp+QPFn3XF3varw/dGriVpyTA/bIf50NX8KDuEpCU7WXM3rQnURHeQ0myM6/qhP X-Received: by 2002:a17:902:148:: with SMTP id 66mr61600037plb.143.1558879262657; Sun, 26 May 2019 07:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558879262; cv=none; d=google.com; s=arc-20160816; b=rRCG8zvFFhSpEqpobhMeqMUetbLadZmFwzAmrtgFg1GIws/4OebDFjZybyIiPYU5Dc JWxh/ab5McFHvLilguBReVFX5oC7GuxKsFhfgg8GjY2jUzRQ7Rqusbs/7UHmHAGj3Ing biq+mUJWplwJBw3zEQJiFwjcSm8b+NRXjXldm38E+/annjGAlnX3tnooQ4tuc2eT9WpK NShfKw7pCiBrjuesk3XDm0dAELjT5NlqgZevi46cfPSv4ommZ8uHnwwrcyBc7rL3spsL UKSp2IidCDI6QfL/KWKepbqxzQE/pjWmTtPlqPwg3DABu6DPIcqZHe5lM5zfOPClsnrI viuw== 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=Q87r3fNmNCP3Biyq3RF0DkHapd6qlpuqLXAsIpA43rw=; b=D1i4eZC2rzFF1wtmUB4ZdMtt0l5u0pIvixBM/vbYecyaZi+HymAAW1NSPaRE1249mU zdVn0NjU6YqwNRI9VdN75Mwh1/7FaD8RPT7oWVaEkIsQQgl/c/mWwqMfM5a0bqmvp8dt CDNG7jvzlBAbKnz+BG1XgNy4/po8pML9BHiAfrUZiO+BfjLf40sa+QTisdFJvAnb9gAn O7x/b+mqTvYegLYNdToSXU8nvoyLlMu1YmRrsAaUCvUl8gaByZylKHdal4ZP0oGDV9YA 6WWcFfhcsvmKHqKbvoG7/Z6bwosJWKGmDGA/2Xb+mLHTCgtxObQiVgVOCW7TM0TRSMuc dsZw== 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 k24si14191764pfk.195.2019.05.26.07.00.46; Sun, 26 May 2019 07:01:02 -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 S1727880AbfEZN7S (ORCPT + 99 others); Sun, 26 May 2019 09:59:18 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:37337 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726995AbfEZN7R (ORCPT ); Sun, 26 May 2019 09:59:17 -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 974FB60003; Sun, 26 May 2019 13:59:11 +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 v4 10/14] mips: Use STACK_TOP when computing mmap base address Date: Sun, 26 May 2019 09:47:42 -0400 Message-Id: <20190526134746.9315-11-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190526134746.9315-1-alex@ghiti.fr> References: <20190526134746.9315-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 --- 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 3ff82c6f7e24..ffbe69f3a7d9 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