Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2475630yba; Mon, 15 Apr 2019 12:25:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCs4Yt9OYnr+iVAy2oKw9A2fLslfSlU4eq02q7gGdpQUG5nvGA6yNu7P+H6b2FlMcVncnK X-Received: by 2002:a62:6587:: with SMTP id z129mr78110091pfb.88.1555356343704; Mon, 15 Apr 2019 12:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356343; cv=none; d=google.com; s=arc-20160816; b=D0MZjHSkNyp2ZYiOYj2O7t3UjWA7QPItpwUq2gj76tfwTvwuQP2Il7sI4hcj5NNoiB OoVOzs2uokyOhXYrv1cOYrwJ/sYwctE431VmhEBltgzuPds88oJIRS3Opyzs0OVVArks WD63kjVGFLzkTIps1gd1X4aZceqn14edmzPou06Gexfh6nKA8rGh84x6aQ+f4e6XUoAK 0l+lpdv1V/7xhViqJwgQNwRVXuVJ6S5HUQ/vTlaSuLaFUT8LfDacxwZwFU8duk3Rffcn UrJNogstwEYHVJEhiyxKlGEXCcU7G8z7CbgAFCmmKtx2HB3IGWBzm775lwed21wibQEA K19w== 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=bk15Oo9fplFNMM12ufaJgBEsaqS4Nd4eH/SLEJnPKzA=; b=qRs7XuT8QqbdQmtzlGitdNEfZXS0N19ytW/NVipspfdoW1lXIWFMDMi/rSHIEzdshJ UJRlb8C2T1WQlCj4MVtOHjQMkF5TcyUYfKnhZZJ4xK/f3d6XRDxA236zhkk2QCGnQ7f1 GW6emYa8xD1QPNHk6mTGlluUYj1uhApYSEHUajLKahU8413J5VobnpJJ6n9v7LViKBHh gNjZfnlMqWrcqnkh30aquyVfRl1B1sG4j2+DAkQCmYHDtOMBvIwJ3345bYlJfwizEweT H8UheRaf4dqEwd2sz95Qmy6ZadyCtM3pz/hG/eFnizDdd3+kU7dOY+W5qqbDYalxMFH8 rWNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vgt43UEd; 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 y4si37770065pgv.154.2019.04.15.12.25.27; Mon, 15 Apr 2019 12:25:43 -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=Vgt43UEd; 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 S1729937AbfDOTG3 (ORCPT + 99 others); Mon, 15 Apr 2019 15:06:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:40780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729871AbfDOTGX (ORCPT ); Mon, 15 Apr 2019 15:06:23 -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 283FE218A1; Mon, 15 Apr 2019 19:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355182; bh=dyU8SptGR47wVkvvFW9x+9YPzMXuAlbY+ZRCe96alh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vgt43UEd7pHsW4Oi34eo0W/ZNlSOvsc6EnsIXfxcUGjV+cmyzTsD0pyv4RvSkooDd dPS4+bKtdvx3psIgZRiviqdfcAbynISSgdkxmPEQX10GLoQJ2rzAZEvv76JwJuzeW1 4g5IiC/ramkelM2FKKc9Dh+7ZgB8fUtohIAlaRls= 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.19 044/101] arm64: kaslr: Reserve size of ARM64_MEMSTART_ALIGN in linear region Date: Mon, 15 Apr 2019 20:58:42 +0200 Message-Id: <20190415183742.921241265@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@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 787e27964ab9..774c3e17c798 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -450,7 +450,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