Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2737499ybi; Sun, 26 May 2019 06:58:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKHInrwpQcfCPutiufr1bRfcByJY5etKg/xY6Jvy1IGe8UBWyzh3nufRFR7yreBvm8oHkx X-Received: by 2002:a63:ea42:: with SMTP id l2mr115653561pgk.19.1558879122996; Sun, 26 May 2019 06:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558879122; cv=none; d=google.com; s=arc-20160816; b=YmX5OasP+zEPqJi4Hq1OrqKBHU4j6VDKFbYaIXZiHxbZ+ugMk5AnXdO/ssLRrYOZ6T 2cue8Cdc6L65XVNXA1FlNoty2drzadEROINHTHKz+Zx4UXAyPSARJ3p2WdexJgRYE0qx LRYxcL/4PJK+V9A6caQvJzH+Uyo0YBYoXUIVsBVBLuxN9n161AwQIMFDJUxH8uHxdVQJ lAAosL21kOLSIA/Jaa7ZHuSRHmkbvGCaJYluNFk3dXtJpBlXhmVZTpv2E9hE8wTuH/m4 hTNhxj3cnnb4ytOctgy4ZgXm2mbF3Fp+Bno0pEcD3PsIUbRx3R14Y8gdbg4B/6L4uPZZ 2HEw== 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=iEUnru/pgX+pWRywt03LhpHMFzmbntBrlVCKRjubFbE=; b=FJDtoh9dnBN3QX66KjhENDzOOEnGtWL3Worfp8okq2PQ1/3rUOV98cLCvUe9BkjBZg 6oJwu91C603eMV+MWu/krKhOykJHtRp/KHqo79TKUJjz4eLaGVzr8rJbvdK0WruKMi1+ tzcVoQnL0nIRfXGp62p9n2++BPhSwhVMVzsTtax1panLNhfJS/Z/DS9ueLLQtTQz2vBI Hn2EGrImMGSW6qtzlmnBqCZOyYcvBm7dPwGSTufxheVEaAFgc385ElZzHiYOv5qfCVLh OYbBjKKzOsn5+dpcvpPq0/KaOp059qSWTapasDjCwdOIsOhlBPiulBhT0GzOnld5Ij99 /cRA== 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 h25si14567356pfn.209.2019.05.26.06.58.27; Sun, 26 May 2019 06:58:42 -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 S1727887AbfEZN4C (ORCPT + 99 others); Sun, 26 May 2019 09:56:02 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:56617 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726995AbfEZN4C (ORCPT ); Sun, 26 May 2019 09:56: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 relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 0B511FF804; Sun, 26 May 2019 13:55:55 +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 07/14] arm: Use STACK_TOP when computing mmap base address Date: Sun, 26 May 2019 09:47:39 -0400 Message-Id: <20190526134746.9315-8-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 --- 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