Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1703049ybi; Wed, 17 Jul 2019 20:25:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeUutUaZDVcruDZw89Tam+pVfVTyHdgvMvmcJnzuum0XH0ZlDsNaTsK/orHdgYAdHevroy X-Received: by 2002:a63:1045:: with SMTP id 5mr44973223pgq.165.1563420327051; Wed, 17 Jul 2019 20:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563420327; cv=none; d=google.com; s=arc-20160816; b=d89mNG5nVSoKvKcP8IE0ZrhmjJoxIKNlZlwNZ016AzoBA18T0+IfMrEBA8O99KD/Vu tWUbEed8xXb6f7V7uLkSRwoJVxMznz7g2AfDsRx7UgN6a5cDI4FrnKx+I/XHQeEmzOXp TuWWK+y8+V0eTnlQxNKG56p4PEzAgiIgGZss58ErLf2pICDqmYmfHfPx8gKc8lZBlQnx dq+ZXdSsGrDWkPSjuhxYHTX0P6YdnxRdXXAs470frjeLnsXQ4KJlx2FM4pegSx2fOZGs KQQ7nUK8uC8Cd7TxVQyea9XAKm+MYPoHX4xXkgdYjAh9huAPx/txSpPqQBMyid20QhKR niFQ== 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=5hjcXiS31KGU8rGcXyamC9qov/nIYhz0vkIeoYrNDs4=; b=pTWPhfeSy2hKjFSFZud9YWphwjCm2qERdIPf9zeY8wayG3phxGy+6omQhV5F4i7CLn w94hFOmmI/CTIa3njMDB3n9aULOQDlOd0o7pfI4Gg6QwO66Mc/a/TKRvb2VEF2blxBe7 ccTxAYAuy/u8U+VE2ENTLAs5dMKaBx6OsUMljGzNkvgc8ODPIErtb3odWjPJq5spFz+A J8+ZGJ6aGckGP3jTmsUKRA09blPKVGEolswnHspkaH/9qCJ+jHaK8MfKdMnR3uyLIqAg uYnrZHJt8H+A80Ivbewm8ShxUfokB300ikrm8CJyR5JFbgGP8VWm85+JvL2HMfvaLgHT mpWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oJyGDDAv; 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 o61si343870pld.392.2019.07.17.20.25.11; Wed, 17 Jul 2019 20:25:27 -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=oJyGDDAv; 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 S2390405AbfGRDHU (ORCPT + 99 others); Wed, 17 Jul 2019 23:07:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:38710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390356AbfGRDHN (ORCPT ); Wed, 17 Jul 2019 23:07:13 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (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 93BE9205F4; Thu, 18 Jul 2019 03:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419233; bh=jGxMWdulzhR058UfyBeS225ZVsG+oHSXokkhjiMLPDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oJyGDDAvCnlJyzOE2U+/nAA6OsZIfUM/sSW5nhurmdhEL5kaf7JJoKIKPKVc+smGV k8O+B5aWqVW4bQpwnnJs7F3Tmh0Snekw6eNdo49u/90903VoCWXQ50kPXenfbNCMFr UMIzx6olFPsa24Z9YBcEMy72dOR5Z01d5CPnXaro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Kirill A. Shutemov" , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Alexander Potapenko , Sasha Levin Subject: [PATCH 4.19 23/47] x86/boot/64: Add missing fixup_pointer() for next_early_pgt access Date: Thu, 18 Jul 2019 12:01:37 +0900 Message-Id: <20190718030050.669792804@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030045.780672747@linuxfoundation.org> References: <20190718030045.780672747@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 c1887159eb48ba40e775584cfb2a443962cf1a05 ] __startup_64() uses fixup_pointer() to access global variables in a position-independent fashion. Access to next_early_pgt was wrapped into the helper, but one instance in the 5-level paging branch was missed. GCC generates a R_X86_64_PC32 PC-relative relocation for the access which doesn't trigger the issue, but Clang emmits a R_X86_64_32S which leads to an invalid memory access and system reboot. Fixes: 187e91fe5e91 ("x86/boot/64/clang: Use fixup_pointer() to access 'next_early_pgt'") Signed-off-by: Kirill A. Shutemov Signed-off-by: Thomas Gleixner Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Alexander Potapenko Link: https://lkml.kernel.org/r/20190620112422.29264-1-kirill.shutemov@linux.intel.com Signed-off-by: Sasha Levin --- arch/x86/kernel/head64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index cc5b519dc687..250cfa85b633 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -184,7 +184,8 @@ unsigned long __head __startup_64(unsigned long physaddr, pgtable_flags = _KERNPG_TABLE_NOENC + sme_get_me_mask(); if (la57) { - p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); + p4d = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], + physaddr); i = (physaddr >> PGDIR_SHIFT) % PTRS_PER_PGD; pgd[i + 0] = (pgdval_t)p4d + pgtable_flags; -- 2.20.1