Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2447036yba; Mon, 15 Apr 2019 11:49:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqysng2wM/7+LJVil0Zf9u7PyZt+ocG0kH2hv1OMZdekC/dWiK2AjHBMG6j0sEOWBRFFX4Sa X-Received: by 2002:a62:1b8a:: with SMTP id b132mr78054343pfb.19.1555354181742; Mon, 15 Apr 2019 11:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555354181; cv=none; d=google.com; s=arc-20160816; b=EIbj6ymWoiWfIGonfr7H+VC1zW576yigIRkLwt3rFf8PCxy4MbrPJtU2hRz0tZLTfv ech56pR4Gsnc57DTejCKw8H7VwjqqTpnOubsL0iqB3Kxeh5pUFcZ10X+So60uzscIBkT El3LCAa5dpuzZQbnUTrCPFfsGcbIzQ5I1dZ5Q9pKXD9Js5Y9Jz4PJ/o3eboPMxFB1afB ftz5BUK5nH8fb5Bu7U47AlzLL8Erxnr+GnaCC1/3Wj5nZQRavnY4fDrJ5K8xW5y+2w2U j+Jb2/QmnuxjmP0nMgQ6wBYyirWbskMaTx3B/d3mufQxOCRqK2FMjRsvQV2Tadxm1bSw y9ew== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jxrgQWoV//XEotsQ4+uBA7LXI4agIChaJZZ7L5zrcOQ=; b=m5T6Zj70E4l2AmzBmXmcmPQnxY/PkRLKuyxuIqKs+R1wiM2N2A2SlDgjdgiW1EC9IB rDW4z5Ao+EtHhTUhKc+QRdNMLIKi37hFW0fLQBJEZ5+M5Bvk3bCKHyytm20UjgWRuSpy Us/3xM1CfT7DfBCyZ9cEQssXRI7inqHktK5aEZDdK5LAOkgMK8OYNDvGmn2Uq783MYLZ CZ+XxK0Lu/xPv2Rw9aKd4URR8BZtENIng1rkhF9C9f4b03KaJzZsiQphNtWy4vPqG2K0 OwTDn0etI49JizMxPgZyesskLPQYkpeZgiBuWBF62vwqVxU0JsGloW7lYSMFp57tIal/ TxAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PkTF9hlg; 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 l62si33188036pfc.65.2019.04.15.11.49.25; Mon, 15 Apr 2019 11:49:41 -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=@kernel.org header.s=default header.b=PkTF9hlg; 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 S1728844AbfDOSrK (ORCPT + 99 others); Mon, 15 Apr 2019 14:47:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:50204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728831AbfDOSrH (ORCPT ); Mon, 15 Apr 2019 14:47:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B60DD218DA; Mon, 15 Apr 2019 18:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354027; bh=4gxW72HfJr5+kkJDdtE9i6Nz5A/Ke0uzBsjxdhn05vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PkTF9hlgAkQTg2ur8jdoQygXNC9hTUet7w53TiMmIVwdeg+y0J52aSM4D2pNqx1gH qOhyEMlpatMkJ4TCnvB0wvHAQYEOYoxtzCP5wOzoUxzf+jS/gWH5lrC1ELYTkduNvV jH4TeprnxY6GDbosyGmC08MUOmcl4Bynllzwb4Fw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , liyueyi , Will Deacon , "Sasha Levin (Microsoft)" Subject: [PATCH 4.9 45/76] arm64: kaslr: Reserve size of ARM64_MEMSTART_ALIGN in linear region Date: Mon, 15 Apr 2019 20:44:09 +0200 Message-Id: <20190415183720.131293717@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183707.712011689@linuxfoundation.org> References: <20190415183707.712011689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit c8a43c18a97845e7f94ed7d181c11f41964976a2 ] When KASLR is enabled (CONFIG_RANDOMIZE_BASE=y), the top 4K of kernel virtual address space may be mapped to physical addresses despite being reserved for ERR_PTR values. Fix the randomization of the linear region so that we avoid mapping the last page of the virtual address space. Cc: Ard Biesheuvel Signed-off-by: liyueyi [will: rewrote commit message; merged in suggestion from Ard] Signed-off-by: Will Deacon Signed-off-by: Sasha Levin (Microsoft) --- arch/arm64/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index fa6b2fad7a3d..5d3df68272f5 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -272,7 +272,7 @@ void __init arm64_memblock_init(void) * memory spans, randomize the linear region as well. */ if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) { - range = range / ARM64_MEMSTART_ALIGN + 1; + range /= ARM64_MEMSTART_ALIGN; memstart_addr -= ARM64_MEMSTART_ALIGN * ((range * memstart_offset_seed) >> 16); } -- 2.19.1