Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp177678yba; Wed, 17 Apr 2019 22:29:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcIuzNbgw2yYJJ+7vCAyZjoz2nfDbqgwXLghHuw54/2EloAxn8ADNs2VY5Fo4jK6atFWlY X-Received: by 2002:a63:bd52:: with SMTP id d18mr86619629pgp.52.1555565349984; Wed, 17 Apr 2019 22:29:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555565349; cv=none; d=google.com; s=arc-20160816; b=y3Fxki0euIOXfPEmvJeooyvilj/jOZTtKEXHonXvV1k3xhXFBerbgfH3e9D12fSJWp LD+giDHznyDvfCpypd7vM+M5V9wtuZwDKd+0OQksxX1C9Thrh17lO07GqVeYhvWqJ0PW bwJghzruUswiofQjSRQ9eTaZq74qGpxhpoM3yeqhDDf1ap5nEo6kzdw9TdmSbfqNX9UR PdUK1JwjeN07r15oiyqQeYtzloVK+VRgZehxn1UIK4ZB4rq4uWLNuyY9o4dG7Ic6uO77 r+fQQshFYfVjDhskx+iQ54ril/858bF3kRtp1FRtx1nFySKSLCFHEcIyNbKEDBXtUbox e/Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ohjMtnRuoMZoK8NFCIw9UXTAaT8mCgqZCZ9c725i5mE=; b=RVcdAlxMStLn78riHcyft+432I3nZxu5yzSj+HxAySNX1nf6+//Sifgs2/bIvrRNdt /MYMqf6uQouD3qJcDpBVvp7YhA9Yp4nBjfPVgEps+VRgoFq1DfZWFCDzQ7CyreBUpYBn xw+7p+lNoyxkQLwvmvlOlE1RGxvFouNhEEnI10uS8zue2HPjR11SC3H2gRt7bbJYPIEW anPoJk5Qkl0r9jUiZ9KxoZDBIftMKoUGMGQOurjIzsghqF3eNfxdMHb31/51T5n9AsL5 T1woozvn1Jw+e23TkYkxy4rd8P560t2BcyBVvsSHF6GNGwKDzvPwrB80Qk8J4Wk+SgHu nxPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hNSJWi7d; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 194si1416536pfu.48.2019.04.17.22.28.55; Wed, 17 Apr 2019 22:29:09 -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; dkim=pass header.i=@chromium.org header.s=google header.b=hNSJWi7d; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731254AbfDRF2J (ORCPT + 99 others); Thu, 18 Apr 2019 01:28:09 -0400 Received: from mail-ua1-f68.google.com ([209.85.222.68]:37663 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbfDRF2I (ORCPT ); Thu, 18 Apr 2019 01:28:08 -0400 Received: by mail-ua1-f68.google.com with SMTP id l17so384258uar.4 for ; Wed, 17 Apr 2019 22:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ohjMtnRuoMZoK8NFCIw9UXTAaT8mCgqZCZ9c725i5mE=; b=hNSJWi7dfZS6icOBYs4kZRM3P2+rnM98qjGabtZHa2binvsfr93Ocxkw+IwxUASlD/ pQX01+gyN8BW8yJYMgeqgS/eAzOZQEpQCg6E3xJ+hbrCPgvJPgJJi4wI0J+FiIbsUSP6 0k+cQm02mdD+oM5hLDG6hhfyjMKa1vlN3OhUw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ohjMtnRuoMZoK8NFCIw9UXTAaT8mCgqZCZ9c725i5mE=; b=slPtIjPUyAqgAl40PVBBRJ3a8Va9kNU3+Nj0Je5aEI6chxdlVZOwuM59tNioGlVWgy hQpOEoojkguVZ+mGgiDJS3+/Tk/GsVEBGg3u3xsBm/giGhC7FH9jeA/EVFWa0G2+kOpd Rx8mVy8ntZLoZizKgaHnyVI5ffERf4Nl8sgdZyjUm8ohNxfeKRc58lFUnmiBsGO+HvJJ LhTli0KhXbLH5KQvoEIK/+ikVMhwVs5zCS2rpv3LiQYSrjB3v7HMEhxBWsTeqFqzCXPn nfm3sO/dnVTIyuHeRclbPdilDF6AHqom80B03GmI8nJhloCdIhGc0nFF16Srby4sNMKs r8Fw== X-Gm-Message-State: APjAAAU5Vto9XIKkLryzTfAAGjn3EsKcF+mG8pNiE0y8KDFYJL/40SbH knAJMe6UXbmIeEJ1JtRKLCACyAELJZE= X-Received: by 2002:ab0:2b98:: with SMTP id q24mr12438761uar.122.1555565287601; Wed, 17 Apr 2019 22:28:07 -0700 (PDT) Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com. [209.85.221.176]) by smtp.gmail.com with ESMTPSA id b5sm199541vsd.18.2019.04.17.22.28.05 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 22:28:05 -0700 (PDT) Received: by mail-vk1-f176.google.com with SMTP id q189so205482vkq.11 for ; Wed, 17 Apr 2019 22:28:05 -0700 (PDT) X-Received: by 2002:a1f:2e07:: with SMTP id u7mr49260276vku.44.1555565284857; Wed, 17 Apr 2019 22:28:04 -0700 (PDT) MIME-Version: 1.0 References: <20190417052247.17809-1-alex@ghiti.fr> <20190417052247.17809-7-alex@ghiti.fr> In-Reply-To: <20190417052247.17809-7-alex@ghiti.fr> From: Kees Cook Date: Thu, 18 Apr 2019 00:27:53 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 06/11] arm: Use STACK_TOP when computing mmap base address To: Alexandre Ghiti Cc: Andrew Morton , Christoph Hellwig , Russell King , Catalin Marinas , Will Deacon , Ralf Baechle , Paul Burton , James Hogan , Palmer Dabbelt , Albert Ou , Alexander Viro , Luis Chamberlain , Kees Cook , LKML , linux-arm-kernel , linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, "linux-fsdevel@vger.kernel.org" , Linux-MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 17, 2019 at 12:29 AM Alexandre Ghiti wrote: > > 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 > --- > 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) Parens around STACK_TOP aren't needed, but you'll be removing it entirely, so I can't complain. ;) > #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 > Acked-by: Kees Cook -- Kees Cook