Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3665235ima; Mon, 4 Feb 2019 03:05:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN4XYX/1f2vU0egxcTcof9yNvald2AenYaAUkO6LcQf8M9TRWHE8zYSHtLJI+w4JyElOUsmB X-Received: by 2002:a17:902:f44:: with SMTP id 62mr51478591ply.38.1549278333929; Mon, 04 Feb 2019 03:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549278333; cv=none; d=google.com; s=arc-20160816; b=VNiZpg47B+OkMJExXBuVgbmZDDrHJBNbqVfM3cqA4h5+QfB6oR34WQQHft9YUFPA0F U07ocGQcnVurYJ2b5J9MepCuCyV2/XQb8NB8yhTuAZCcf04SH+wLS4X6ANF81vCrVBC5 EkuiXTKWqMdYVn3w0w6VbsBbqEKf9OTQfyyum0ut9MkPnxxCpkiQd1bm0FaCSLtqJl9V 2fbtCQOoffrjI2JWRzBwFnCYcsL2FK28AZWK3KQVzVZhsz7VdxYVr93XgUgrIEZcwHEq apBbNI/xseHhNZVGjHet6VLP/WEU3f3n2U8MGl1yEOLcuWBO5s1RuRBcVYoHTNqr+IAj 7N3g== 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=qFD3lU+sP4n1rVNB+Anm41zLUVepgBbJQHdy7zrpoi0=; b=rPBgja8hJuK5hISjrGOjRAdCzEt2E51JSViv0p2Gjk6dY3sud7+wZE5bJVDRlidnOD agB3Sji9WFaXzbhYAgDLdHZxBmZL52mxkUEw3zEWT3IFB3erdAN38Yxvo1zGlydkSn/L zTE8GE17b3iiUSr1Njx/4H8xSYJd1cmL9zOnWU3yiYdWWyxwWqpccoALu1CO8PmEL4kc jdYuoIRBPDbzFEYMMHn8tGxvtENjThqlEB8PQKYGGFLe/gOvGHvQsZzgLUvjzZMcFxGs H4jHpeRwS8FGXX3TX7CkkxshOvCALGcOgPpTLJnN8IlJa0axFq6Mezdhv5yIZNw+t7UD JByQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q9oeV73h; 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 x3si14417330pgf.453.2019.02.04.03.05.17; Mon, 04 Feb 2019 03:05:33 -0800 (PST) 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=q9oeV73h; 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 S1731356AbfBDKqM (ORCPT + 99 others); Mon, 4 Feb 2019 05:46:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:44358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731350AbfBDKqK (ORCPT ); Mon, 4 Feb 2019 05:46:10 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 F4021217D6; Mon, 4 Feb 2019 10:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549277169; bh=496DgQahFoBAya8f0wELTpDV0zqW7Q/+FuevApmtA74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q9oeV73heepf6oF5so6F1R88SC4KRgpzuvQ8ScmH1a45inW6dU1tfmfJHRVVPrWlL w06z+9ye7PbeutELEt50aU6tUoNe2VAohXneqFIzgMzgPM45KzsDWBSB9KEkivIGAI qjmXCfTpvCfnFG9uOid+/GKmyDvWpX/1jBq9TwHQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Will Deacon Subject: [PATCH 4.14 26/46] arm64: kaslr: ensure randomized quantities are clean also when kaslr is off Date: Mon, 4 Feb 2019 11:36:57 +0100 Message-Id: <20190204103613.128089789@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103608.651205056@linuxfoundation.org> References: <20190204103608.651205056@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel commit 8ea235932314311f15ea6cf65c1393ed7e31af70 upstream. Commit 1598ecda7b23 ("arm64: kaslr: ensure randomized quantities are clean to the PoC") added cache maintenance to ensure that global variables set by the kaslr init routine are not wiped clean due to cache invalidation occurring during the second round of page table creation. However, if kaslr_early_init() exits early with no randomization being applied (either due to the lack of a seed, or because the user has disabled kaslr explicitly), no cache maintenance is performed, leading to the same issue we attempted to fix earlier, as far as the module_alloc_base variable is concerned. Note that module_alloc_base cannot be initialized statically, because that would cause it to be subject to a R_AARCH64_RELATIVE relocation, causing it to be overwritten by the second round of KASLR relocation processing. Fixes: f80fb3a3d508 ("arm64: add support for kernel ASLR") Cc: # v4.6+ Signed-off-by: Ard Biesheuvel Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/kaslr.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/arm64/kernel/kaslr.c +++ b/arch/arm64/kernel/kaslr.c @@ -88,6 +88,7 @@ u64 __init kaslr_early_init(u64 dt_phys) * we end up running with module randomization disabled. */ module_alloc_base = (u64)_etext - MODULES_VSIZE; + __flush_dcache_area(&module_alloc_base, sizeof(module_alloc_base)); /* * Try to map the FDT early. If this fails, we simply bail,