From patchwork Wed Apr 17 05:22:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 10904559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 516B613B5 for ; Wed, 17 Apr 2019 05:32:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43A2228915 for ; Wed, 17 Apr 2019 05:32:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37C0B28A00; Wed, 17 Apr 2019 05:32:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0E2F28915 for ; Wed, 17 Apr 2019 05:32:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28E6D6B0008; Wed, 17 Apr 2019 01:32:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 265756B0266; Wed, 17 Apr 2019 01:32:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17B476B0269; Wed, 17 Apr 2019 01:32:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id C2BE16B0008 for ; Wed, 17 Apr 2019 01:32:43 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id h10so4056454edn.22 for ; Tue, 16 Apr 2019 22:32:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6D+bml0GAKMUKHe87npe+2LGj2+9T7+GwcJmjpz0elM=; b=avxJDEKVgoviBboW74xj9KkOFcMlXOlHOlsYHQexHEkyp4XLEOPCKCMnBQY2secwCg SYvDTc9VMqxt6qLttkfqpnmaXIeC/Wxi/XjqgVWPE3rUFRh4JgxOdSjgn/E2TWuuTyJ7 /u6Po7upVG4U+ZRJJgOj/99X2/+B6T1J+Dz6bbHBYHgG/4wodmFx8gyK+6Wckwg8qxE9 7FMuPAWyBhOu/k9uxqMASrfJkhVUAYjaL1LCttKISOmabCliAS0cO3FTCT4dQhYS8Qfd sSEi1+LBetdxXa5WzCKC7A2hUO8wIVJcmb4fgKLHnjNiGpo5tvtBglwbpuXZjUF3dWjY r02Q== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 217.70.183.199 is neither permitted nor denied by best guess record for domain of alex@ghiti.fr) smtp.mailfrom=alex@ghiti.fr X-Gm-Message-State: APjAAAUnyhA/xzJIh71YqK+7V5+BXIJLCzfNeED5wD6m+mazLIWRy7Gr fKxwgdMt4zWR55q9QmW3OA9pG8GJ+Ws9whZXRwna0KV91jRhI9NAD0Dk4+KV/pf5VTNEFepG6Y4 yF7wjd2i16Pd/Ofx0RcirQqMTFfxhcACgGEQeTkwidfGiXsO3Rpo2S9rGaEaTKXo= X-Received: by 2002:a50:c44d:: with SMTP id w13mr25701070edf.50.1555479163323; Tue, 16 Apr 2019 22:32:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHjs7/Zoo8NiOu9FhNS2OJVaUQSjg6RW+5oq9zeY2IEwu6KiInKs5TGYndUesL8as/tn69 X-Received: by 2002:a50:c44d:: with SMTP id w13mr25701007edf.50.1555479162318; Tue, 16 Apr 2019 22:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555479162; cv=none; d=google.com; s=arc-20160816; b=L2/vFXMum486HcFfBADhIboNcmGL5gxoibZ/HE15s4mLIysFfGPTTFmdv14+sz/x9v JeeftW5ThfYcRJBz0oDKxFZJhkr+Pp1ut0PxlooS9mIu16iLnrFLilNOpVTHu+r8UNY5 sW373Y6bf4rcn7mcxbOBfHcTzVaw5rpR4gwqScwf55Q3ymlQZl7chdq4hEZQiyDzbnD5 NG6aOYE7WE623nr5SCRfjv9QZ5rCCObwf0anuzCs8FDK+fNvxcpfHOn6b/O2Fh8u2Yz8 vkyxuusB26oOWgS6HCCC4QKTH9TnUY3BWfj0YCCWsSyxmtmbSWd/nzPJKlDRXFFIp3TD DK0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=6D+bml0GAKMUKHe87npe+2LGj2+9T7+GwcJmjpz0elM=; b=gk791zp6J//I2i6vg5GSt2NXn2SAEvqSiIzFM+H0yZkIrekRib6yI+vBOVrE/zPgSZ 4cj/fCgPlZlHuG/m5iCaWkTk9jbwo5fe23ri6SSdHxYL9iDyagPWFsQiX6aicJtyRaKd biIt5T0q32DhYKjN1yH5BABuXeTko/Z7lSaf4jg9Wwfu6xctolAlNCrFVObLEqjNeU5w 8nKo3nANLi9h5E3OhkWXb9ps2wwQNUqPXNzpOvZMKP2QWVtsRczWVFApMhf+3NIRLSLl sJKj073MAymKTOl2MJjh4J+82qn1x4ljlPzzNBQ844e3lKihxeGoBVZG+iCbH/9Ot3AN 0j0g== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 217.70.183.199 is neither permitted nor denied by best guess record for domain of alex@ghiti.fr) smtp.mailfrom=alex@ghiti.fr Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net. [217.70.183.199]) by mx.google.com with ESMTPS id d6si5581786edo.288.2019.04.16.22.32.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Apr 2019 22:32:42 -0700 (PDT) Received-SPF: neutral (google.com: 217.70.183.199 is neither permitted nor denied by best guess record for domain of alex@ghiti.fr) client-ip=217.70.183.199; Authentication-Results: mx.google.com; spf=neutral (google.com: 217.70.183.199 is neither permitted nor denied by best guess record for domain of alex@ghiti.fr) smtp.mailfrom=alex@ghiti.fr 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 C815DFF80B; Wed, 17 Apr 2019 05:32:37 +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 v3 09/11] mips: Use STACK_TOP when computing mmap base address Date: Wed, 17 Apr 2019 01:22:45 -0400 Message-Id: <20190417052247.17809-10-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190417052247.17809-1-alex@ghiti.fr> References: <20190417052247.17809-1-alex@ghiti.fr> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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/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) \