Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp144588yba; Wed, 17 Apr 2019 21:40:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTFcBo4d1Xm0JoqTKp/F9yXwr9uQsdInAEEPB24Ec4iQWNFIBUm4ieIyNDJHC8I7p+Ch/R X-Received: by 2002:a17:902:a607:: with SMTP id u7mr94666682plq.66.1555562430131; Wed, 17 Apr 2019 21:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555562430; cv=none; d=google.com; s=arc-20160816; b=I7NKc+U+TR8qHKpXwmQdFTRBhgxMXyt+bgAYQ+A8L9/a3wXlFwr+/ZCsgvguwwGE8j 6dU0hMmGaqvNUODqCy5v3hnEAmBIx2Cn4hKhDUFjmvSaPxh3rz7TDA60ZlKl4TleaalT xqcOPxvRnl+w+LTQiR/0viepGH3O+yZT4whVJA4gXqaThOsHG6y57lthXDRaOVwhaYQj kpRb5rMrMGZSAn7zKAFPfcI62+VH4pAAalZW184QeOVY447nrs+E8VKUTWc4VPjoRF0N Q5G//BhY5R7lK84zD3UODThOkDptRLOV9uoU4Wvur+8Q76QVjpZLaaM0O33xCJV9ayXE LTRQ== 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=92tRgfUMbeMv1ITsQnVX2nfQxbImxEmC6NtEESfsrL8=; b=gP1kX/ZMe0wkZZNnp9WohcVCaxS8Ghp8vPwW07rYsUQmKmlSrW6s0omDDhAVxjmJR4 o0vu0pAF3KMnYIGxx9mxoTS30IpavnItFYDjrhuRXMpwNIkSc+YKcSAcCZOTsCdSZaqz aJXFvTDGnK0eFxKO7uvAFL2yMtlFmG7k7BQCCK31agUT2vvBeNMNGkdp/o21d6/x5lOF R6lCxTruae9Io+swGJTj9CETHShrwRKW2DW/BK/0fm80MNpQkV9q+d9YxvicWfgvh/rq bC3eWz5c/xQiM8LcRX3nMIJAx2ODDe5pa8dUSqvmqzScSHQcZePE+LVmfWdPYpF8Ly9M fEvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OLkbJU7m; 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 q137si878270pgq.58.2019.04.17.21.40.14; Wed, 17 Apr 2019 21:40:30 -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=OLkbJU7m; 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 S1726940AbfDREhP (ORCPT + 99 others); Thu, 18 Apr 2019 00:37:15 -0400 Received: from mail-vk1-f194.google.com ([209.85.221.194]:46024 "EHLO mail-vk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbfDREhP (ORCPT ); Thu, 18 Apr 2019 00:37:15 -0400 Received: by mail-vk1-f194.google.com with SMTP id h127so186089vkd.12 for ; Wed, 17 Apr 2019 21:37:14 -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=92tRgfUMbeMv1ITsQnVX2nfQxbImxEmC6NtEESfsrL8=; b=OLkbJU7m0JSpwXyWqa9ZSVBZbJJbsitwwGD9ZFTANpCONTXMGZ81AhxDTno9r38sEv Z0JotjuwKOUss922IFDFo/63cZ+UAJRNvTAAAwjPU190WnPbTuipbvAcYF0az0veXucS uACiUuIuiBILnxrE6ReQLiWsvSB24QasvXBQc= 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=92tRgfUMbeMv1ITsQnVX2nfQxbImxEmC6NtEESfsrL8=; b=X4PDbq3aRwzhZxwqGWEevuHUDKL/5CBhUfBp64T29MefgM63t9YIshKJ6b6Jp1VQZL +XmQEitYIChTNGlGyMKs2CLXRrLcsBR5MztIeVXhYqI9OKJUcRE2rX7xHGmJ6JA3fVh5 cUOJ7Um5aux+h6m7017kWjKB3ORZAUWZEYJtKsQef7I7xrYbeTlp4bVvEUBDHyNZ13j6 DpeGUQspBrxgRpweAvtJMMDTsDD6Ax56fqX42M7qLNUEWiuLz69s/hm0DQ+MN+VSuf2n 2SjoQXzI6pmLwn2OtVnOiBaVZklxCyvtFhXZoh9P68pn40ufp6iORDQwnCmcliV+GSh9 Y39w== X-Gm-Message-State: APjAAAXGwZ60PxyB9nqDDON7jW32OdEbIlMgoX0WiFIWG1TcyO5WCcCz NHd2TapNv8ldnuIYGG2qZOWBBXWgtmA= X-Received: by 2002:a1f:1185:: with SMTP id 127mr40822199vkr.6.1555562233712; Wed, 17 Apr 2019 21:37:13 -0700 (PDT) Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com. [209.85.217.47]) by smtp.gmail.com with ESMTPSA id y127sm174698vsc.26.2019.04.17.21.37.12 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 21:37:12 -0700 (PDT) Received: by mail-vs1-f47.google.com with SMTP id s2so460020vsi.5 for ; Wed, 17 Apr 2019 21:37:12 -0700 (PDT) X-Received: by 2002:a67:7c8a:: with SMTP id x132mr50675686vsc.172.1555562232106; Wed, 17 Apr 2019 21:37:12 -0700 (PDT) MIME-Version: 1.0 References: <20190417052247.17809-1-alex@ghiti.fr> <20190417052247.17809-4-alex@ghiti.fr> In-Reply-To: <20190417052247.17809-4-alex@ghiti.fr> From: Kees Cook Date: Wed, 17 Apr 2019 23:37:00 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 03/11] arm64: Consider stack randomization for mmap base only when necessary 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:26 AM Alexandre Ghiti wrote: > > Do not offset mmap base address because of stack randomization if > current task does not want randomization. Maybe mention that this makes this logic match the existing x86 behavior too? > Signed-off-by: Alexandre Ghiti Acked-by: Kees Cook -Kees > --- > arch/arm64/mm/mmap.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c > index ed4f9915f2b8..ac89686c4af8 100644 > --- a/arch/arm64/mm/mmap.c > +++ b/arch/arm64/mm/mmap.c > @@ -65,7 +65,11 @@ unsigned long arch_mmap_rnd(void) > static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack) > { > unsigned long gap = rlim_stack->rlim_cur; > - unsigned long pad = (STACK_RND_MASK << PAGE_SHIFT) + stack_guard_gap; > + unsigned long pad = stack_guard_gap; > + > + /* Account for stack randomization if necessary */ > + if (current->flags & PF_RANDOMIZE) > + pad += (STACK_RND_MASK << PAGE_SHIFT); > > /* Values close to RLIM_INFINITY can overflow. */ > if (gap + pad > gap) > -- > 2.20.1 > -- Kees Cook