Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3646916ima; Mon, 4 Feb 2019 02:45:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN7gjbej1xqstIRN1UZtRRPN2kJrZU7Qlt6MPtPjGglpHBgbWwqLI4iusRAsYeEvhR25gUVb X-Received: by 2002:a17:902:6f09:: with SMTP id w9mr52214674plk.309.1549277137733; Mon, 04 Feb 2019 02:45:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549277137; cv=none; d=google.com; s=arc-20160816; b=q84ILqyeEzd4qNbzgFbXHnXXcXsd/yKvVReb93gkvaSiYp7672rXM8GOrkuP0glCTi iKulTrz8Y9c59uF6/xCKRglSBSmUpi5fdmTa7J2nz+smtSXJLpkSgHSJC+wxFoh6dVo1 Z2t1/U+4LAt1bbUrL/K/8uLP8XOp9PyS3yybizZkE/8lOdqV2IQSECqm270+s9rxyBlR QCkgBlb/BN8z2fjimeg4A7FzVCitSWVapk9dXCdEjZn++Pv4Ah8Zd9a5Bxjz5Iog3+EH UcOfgNIfY31o2Ax6Ywr5vcUIsLqttWL5IbakeIDFDdbMVsXwlvFq8CTgR5yxMcEDOWHi hlvA== 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=2/CEdlj3Y9B3XC0bIbJmZm6mbBg6mQiCDb6XYnhcCoU=; b=TtSe+oIB16SL2wGb/jMqhz5JnW3B0fOjFuetOX8oeir/Vd2gTu9hX0pB+o6fB8BFc2 +lKyYpdJEuVe1uPXDSPKUXAytHiDpwJOrgaED78a5I8NkrMZsMOmtrU65wSBcqZJe+mV sBejoOPRUNApJeUvy9rfwJqGCOhuhBIzigSTE2nrXj7I0EEN3j/rYrbz/atIjwbFEDQj ABqUDfTW/lwke8qRKrIC979mofJYxS7YyLtBIaxhJAtoP0DV5RIpX9wg7+Fw3lECGdrN 0az21D5IgPbu/Q4dLZ+VjkTcKguHNMRfTdGsXvf6ayklVvwjhXHEurCnwpG51jhrsg49 Iaaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QoOtHZYq; 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 a90si13279311plc.314.2019.02.04.02.45.22; Mon, 04 Feb 2019 02:45:37 -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=QoOtHZYq; 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 S1730689AbfBDKnN (ORCPT + 99 others); Mon, 4 Feb 2019 05:43:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:41040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730679AbfBDKnJ (ORCPT ); Mon, 4 Feb 2019 05:43:09 -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 9A59B2070C; Mon, 4 Feb 2019 10:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549276989; bh=ySYLxYBIliIaUh/pXELpQsOSBKzwS723r1cAU1OpuoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QoOtHZYqym1JBnAlLiwwlh0jn8EPY1UySUjHadHWMmfPN6+VkG05/l9hpnF+OZi7Z calKbz6TI+7YJB3KyXFHjnltFvVfy5JMjlxDKesr2gSeOIjdhR4x+JfAkAy76anqCs HRIOeehUvlSdNHhcDHFnyeVCkcyNFWmZ3sMkA4JY= 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.9 16/30] arm64: kaslr: ensure randomized quantities are clean also when kaslr is off Date: Mon, 4 Feb 2019 11:36:54 +0100 Message-Id: <20190204103608.393706026@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103605.271746870@linuxfoundation.org> References: <20190204103605.271746870@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.9-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,