Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1876848pxb; Mon, 13 Sep 2021 07:23:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQbASYL5dqPsC/XS/6qiztUYaZHeHc2BIQF/IpKkFnZHmsITYOM6Obx5gzRbAABMMsaArz X-Received: by 2002:a6b:8f4e:: with SMTP id r75mr9474864iod.172.1631542880209; Mon, 13 Sep 2021 07:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631542880; cv=none; d=google.com; s=arc-20160816; b=FakCagjXh9hxoWQLd0OvXWXm4KQRwGMikuRxaq1cSFgVAg9yk7PzqHk+P1aP3mmoE7 xeOCILjWmGc+ogTk97CGnWJrg5NOxZiK1qhLe0r/lPUwPFYzPquLOPHtUCJWSe3h4vTz lyA+xe6cy2zhHmcHw+Ch+84Db+SeU3MVilrkg0SUqDCCokG595ovPljgJl/ABJ49hg20 YDnrl0X+OS3TTRD8lrWchjgnEG78kQ56+3C35IDB8N6ieQGwjsANsNZfRqxMfBCMjswE FUXqcj9RRvxldT5d4Ol2hSGMVqSCTgVqira0K3oc3OVfbcN5/zRtlZw3hwWoIc8U53EF 9C9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7KyczzXguuBFUvm9vVVLXVo2ZNgjvXlmLpy2hOz8fxM=; b=AQp6mBqrs3+dHu3yRimZx95gwk/gzYgm1efDV0XMylKeQAkWXorfQMmBjs7bvdItN3 Y0YC1q0ryvuHxjipxHSb/P8XbTk0aU76wBhMElvaBhV0Rb3lwBdc5PVBpCKJjtqnfueR tbACd5AdRFLlUkwVNwYmOCmZxfqfJH5/ySUCSLI9HgN96GFn73NiIRrooeCbyqjs6Emq I9RX0MbPuUQNsv4kZOxsHqEQqpPP3b8lBNAPQNx+Y7woY7+30nYFcvA4VMEs6euwxUs2 dOVsPqYtDx8xL0rXpaJwAI+mFCslq+NxjOFjD25RvFTPhDFfeK4wRmsHU1YFemcbELT/ Wfaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OT8oB12X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si7308370jat.53.2021.09.13.07.21.06; Mon, 13 Sep 2021 07:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OT8oB12X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346096AbhIMOUl (ORCPT + 99 others); Mon, 13 Sep 2021 10:20:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:39402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345176AbhIMOQf (ORCPT ); Mon, 13 Sep 2021 10:16:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F90161503; Mon, 13 Sep 2021 13:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540669; bh=ZI2RwZELHwe6aemmj4IUnpA1Vaby/xF86QnxPs51RVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OT8oB12XkmHzv7LtvIaYmmmzCIAlBWgSoXfq7RH/NVGF9xvyVtYWICRSzs59xmYnG cZsPHyY/pg02N4EdqnbwnAtUAe5khOIvf9WPUBdprTc9lgL2omjHGg07w51o/vcYKd nw7TySkJtZqtxipMuhYfLqEZL6v2pCdcIIfhJLog= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quentin Perret , Catalin Marinas , Marc Zyngier Subject: [PATCH 5.13 287/300] KVM: arm64: Unregister HYP sections from kmemleak in protected mode Date: Mon, 13 Sep 2021 15:15:48 +0200 Message-Id: <20210913131119.038999560@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 47e6223c841e029bfc23c3ce594dac5525cebaf8 upstream. Booting a KVM host in protected mode with kmemleak quickly results in a pretty bad crash, as kmemleak doesn't know that the HYP sections have been taken away. This is specially true for the BSS section, which is part of the kernel BSS section and registered at boot time by kmemleak itself. Unregister the HYP part of the BSS before making that section HYP-private. The rest of the HYP-specific data is obtained via the page allocator or lives in other sections, none of which is subjected to kmemleak. Fixes: 90134ac9cabb ("KVM: arm64: Protect the .hyp sections from the host") Reviewed-by: Quentin Perret Reviewed-by: Catalin Marinas Signed-off-by: Marc Zyngier Cc: stable@vger.kernel.org # 5.13 Link: https://lore.kernel.org/r/20210802123830.2195174-3-maz@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/arm.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1957,6 +1958,12 @@ static int finalize_hyp_mode(void) if (ret) return ret; + /* + * Exclude HYP BSS from kmemleak so that it doesn't get peeked + * at, which would end badly once the section is inaccessible. + * None of other sections should ever be introspected. + */ + kmemleak_free_part(__hyp_bss_start, __hyp_bss_end - __hyp_bss_start); ret = pkvm_mark_hyp_section(__hyp_bss); if (ret) return ret;