Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6403609ybh; Wed, 7 Aug 2019 23:27:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqya051oh0V5u2kiqrhSHe5yaCI3JbChN5hnAOsVRfL2ze8osAbG9DBDZarHtj8GVNVrKv1s X-Received: by 2002:a63:6fcf:: with SMTP id k198mr11191259pgc.276.1565245674552; Wed, 07 Aug 2019 23:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565245674; cv=none; d=google.com; s=arc-20160816; b=Qqozr9odB17E9sajgn7QV56Kf0+GxH+6Ny0IEvl9rGYjZG4lGldlSgsQWWdaedv8OV jP0WBvbnfHeUSPTyM6/Tje0qYWMtOQxHQVMo35JlKD0U2sdkOS4T474NBEay08Y3DHLG BDTwsEcgjy/scG576saV3VOl8h+oVZj23B0Sj05AogMV5kop1PmqszfmYeiIhO+9rgwh ERX0H+IjHt9Ux6Q0Sfuu0odZ6agxvGPzWjtesMD0+2gOOjk+Iq+DCaviQj48a9gJDxCM SDLOGWUlssFqM1ObFQppd5vs8WeD4wfNw3X3HqS/wX16GDz57uc5CIwXMjGXKkFgPBlk SAOg== 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=WYZFBi/mDjw2AHO/7J+UsrC2CAAthlR5mqmiph32kXg=; b=ussS/NA1NxKQk5YXxCcZWS/ZcmAezIS0iATLOjh1JIBcpz8n00C7SN6BFOXShupGmt 0T0RYgN35nLlaU67NC/5fUrG0UK5lH3fQPLVH/CLvF24HC5PRjGVUJ/ONFBciJpXLK/m MvIAZe5poy9MwBMatQ75mDF5dnhhHX8SW3brlXj67K7JY01eStrPeHe3wgtY4/EwE2RZ AGuJKkaJ1m74tH/uUQ1Hn3uENtjLG3QGjb4TiKzNetP5q9um35+Q46FIr1dCDP9K3/YG cvsuRiNrspotPnVNfW8qfNWJQKipKGlCZEziBkjzz816INTQixbCk+b5uvlxrb6f4dhv SqqA== 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 q4si14298902pgv.106.2019.08.07.23.27.39; Wed, 07 Aug 2019 23:27:54 -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 S1731281AbfHHGZr (ORCPT + 99 others); Thu, 8 Aug 2019 02:25:47 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:56611 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbfHHGZq (ORCPT ); Thu, 8 Aug 2019 02:25:46 -0400 Received: from alex.numericable.fr (127.19.86.79.rev.sfr.net [79.86.19.127]) (Authenticated sender: alex@ghiti.fr) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 4A8C8100003; Thu, 8 Aug 2019 06:25:40 +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 07/14] arm: Use STACK_TOP when computing mmap base address Date: Thu, 8 Aug 2019 02:17:49 -0400 Message-Id: <20190808061756.19712-8-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 Reviewed-by: Luis Chamberlain --- 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 bff3d00bda5b..0b94b674aa91 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