Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9167642ybi; Tue, 23 Jul 2019 23:11:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOVp5pwQpZmdLOIFpJWVJ3KPc85CcdzQNbFsoNT0+21snWYuU2b//iw0BuK5cixTVQOoYN X-Received: by 2002:a17:902:b789:: with SMTP id e9mr81977959pls.294.1563948679076; Tue, 23 Jul 2019 23:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563948679; cv=none; d=google.com; s=arc-20160816; b=fi9Povulu8RfgtozS6Vv7J6uf+qkrnXzKp6I/W2syO7wFYcgsQufjdv57qWJz7p2J1 HJpImOixsr1+rsaPRwqCAX+kiKyELVAjIQcD8OtvyZ2j9Zm1KrARfRAFB8GGZvJmHkE8 ZbYmwUb2iQZQhY04bgHG+wmwgh5ZwC+YwLKOCwfHgWqcnGb5heKuML7J/ZTO0biwBAGl GZ0KmZs7BnHcJ33Lo8YK9kZKS78tcd+dFxjStueJxoy1AwZVwW9dk3/dLnb8BWXBE+qJ Q9vdxvqIFwN1vpMfGURwETJa1xu0kQb5wnZS18pmgEnGIt2ZUWTybQL8UxaUVWHCD3dX oKZQ== 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=LxxYxWqxNkL+rNpCPJA+2SpcBDfwJZpToQa21YnSig8=; b=bC01htWC5jsU+CbmirQqCVF671hnhYk57Vlj85C0QvkhesC9hn8DDk6JqOxWfmN2SV bggHZBCfvuaW/eHRqb9Nmdp6nUNVvbUPfvBqShJGmtfmQm7oSNfkTSKkhhNEn7QClCpi vfDP23tO2Xy7t/dEuEgyTH+JN2efChStqE1DKIYrinUSHQsCxKj1Rruq+6UxjCjaMJzD XJP/+OgmwSl/sd4/3SPjwFal78T0B1VTYl/eGpZvOcrS4ZWnWAylw4rp/l05mJ658VPR OdnUFAi3YH2xCuyYECC3NM0Ypl0DWAUKr3v0JjWM0qeUVzsv8qCYkX6+qXC3FXeVbW4W BMyg== 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 b93si13651609plb.11.2019.07.23.23.11.04; Tue, 23 Jul 2019 23:11:19 -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 S1726178AbfGXGJ6 (ORCPT + 99 others); Wed, 24 Jul 2019 02:09:58 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:60499 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbfGXGJ6 (ORCPT ); Wed, 24 Jul 2019 02:09:58 -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 226A060008; Wed, 24 Jul 2019 06:09:52 +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 10/14] mips: Use STACK_TOP when computing mmap base address Date: Wed, 24 Jul 2019 01:58:46 -0400 Message-Id: <20190724055850.6232-11-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 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 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