Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3857333yba; Tue, 16 Apr 2019 22:27:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyP6scZpfh9humPxlVjasPQdOItaFJBzOG3FOjZRtDxOgBO2o8TMF3DC9nclPl6R34g8TWl X-Received: by 2002:a17:902:e287:: with SMTP id cf7mr59192395plb.217.1555478838825; Tue, 16 Apr 2019 22:27:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555478838; cv=none; d=google.com; s=arc-20160816; b=Gn8ISRdWxZsTLs5ILskvJFFJLs41Glzj0P7T+nYfUG2ewW/byW38bQa8fkEIwVRn4q 3NUZPBx7DR5ykijHE8dNwmGtHW1UrS7tCZHvMP+fY+uze5WZSie8hWtUHL86RyAklCfl r47SN3JpZySmTsyrioJhZjYwUu6pQLky6vf4A/dfi3+h6xOnAgOSAmsA0/d3NsSmNaD6 ebFZEee69p63s1MVMljySzYlepgpsPX58+q8kY/MAFNT4TFzTxE+61z7KBTgEQ9TgKIw Hzd9xLPRaE73t9eA/7450yagQJr6XN1GfR3x4kyDy9I1KrhMBqkjIJzDbhjXF7u5S7uk 9NcQ== 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=jI/ny0pZOck4kyabjqWPla9k4gZ6U+crF7GP5DfyIb8=; b=cmZ9ngVsNS13gM68CfOK46rJYL5mZY0aoUUEGW3yizDZiYriyI239iC5DEp7n8Th68 8a1raW4t+yxoY8yCn7LMW+Z15jUauZXEbE+ueM+dfWA/oUOWW8xIgY8OduReTjmh+CXw oo3dqqZqSq3fPJV/j/ieul3PbwhNsCNbXEovYvws/19EDF03JOnFk1cnSjfjX9kjZI3g 5tkN8DkHOhbBUTdNgbeBVV/ZztyM20K0+GtG0fz5nGtx/uowxDYNC0eWnJEjaUTrApKv 6MYy7KZYi10tXUKwbfw7SpCt9HTgpnA5Zs0yYriltMD86pNvKemhNH218ZsSX82XX100 i/vQ== 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 m72si55889108pfj.279.2019.04.16.22.27.03; Tue, 16 Apr 2019 22:27:18 -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 S1729649AbfDQF0M (ORCPT + 99 others); Wed, 17 Apr 2019 01:26:12 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:51399 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfDQF0M (ORCPT ); Wed, 17 Apr 2019 01:26:12 -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 relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 442A720003; Wed, 17 Apr 2019 05:26:05 +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 03/11] arm64: Consider stack randomization for mmap base only when necessary Date: Wed, 17 Apr 2019 01:22:39 -0400 Message-Id: <20190417052247.17809-4-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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not offset mmap base address because of stack randomization if current task does not want randomization. Signed-off-by: Alexandre Ghiti --- 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