From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384760; b=ibhHNqL0zCYacVbdIzsc/2/z/yYZE0gMfhEGEaeC4vqIaLIZvPmPe9Ru5rM4ijTncWng 7HkHlFsaaf1ZiE13ksVJSQGKoAYgqUC1U4gAlBRoTlbsNnOM2FMBX6tJ2pP7a8QNcsVB/ 7i7v17mOVmYpLva/k/FnzDQ7zGGLmOMoR7nBBGGvV3T+dq9dHhkFwBHf4NDpxAwt7AWVd 9+CvL5A9+39LK2ldSQS51a55UazdDesjIWF9LQ1ChzkZziM3/o2KKMtKUnFO2ZHtdSs2e 1bvijmGxd5EaIQcLjUtulhQ9FXsl2p1Yj/DFm/MPFRgYa8EIAveaN7n/FhEsOT6948w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384760; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Swjeh0QE0X6EWJGId3PT5Btb1DH1cWjU//qxc/N7BKE=; b=27vWeh5QbZI49SrXipJpSKWP+OE2RY0LNOsX2lrmGqrKiq2X+v9MJYfn7eOvn5n72Qp3 xXvxJPZeex1NO1Ted1xMsGzME+G5zVhNGru2XS4zZtBTpJ/XFF5oCJdok7tHx9MiUFpHk 7QkWnf0e8zhfY3qiUjo+oI6qszRoH3I12Tj3LvSdayusmuTEygA6C2T1bGAaexZ9r/v3T rlkr1yx+lQhiIAsqownHz4SPsazCfOVBhwSqPB9zYimlWjBumzy2WNfehpdXp9zT/Zi+y AYYzbHSay1ZzEfG6Sp41TkdAreQA6XionTiVTIimEw3ghKplH+sH0ESV80Eo7/EBuUA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=DYg4lfn5; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8F12606A322; Fri, 4 Dec 2026 11:46:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=DYg4lfn5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 035E21F000C2; Fri, 4 Dec 2026 11:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384760; bh=Swjeh0QE0X6EWJGId3PT5Btb1DH1cWjU//qxc/N7BKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DYg4lfn5tZGIFfR9tCDH2gtZ8uXNWmhSnSx06P+GTXXMM0NpLPz0fLm2h0NMSplcg YnYhAPRrwMF5K3o6jQCPkh40qFTSacuZhYCy9KHaGGHtt/dljosKoanld+zdNLcdMC Gsc7TZlfD7z5tuOqZVMy4I1KmxRmS7R/rxMs/2r4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuho Choi , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0241/1167] ptp: kvm: x86: Leak clock_pair page if changing its encryption fails Date: Fri, 4 Dec 2026 18:54:28 +0900 Message-ID: <20261204100708.347226554@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yuho Choi [ Upstream commit 6a01fb125ba6474cb97f14b68fe5435d3cdd08e5 ] In a confidential guest, kvm_arch_ptp_init() shares the clock_pair page with the host using set_memory_decrypted(), and kvm_arch_ptp_exit() makes it private again with set_memory_encrypted() before freeing it. The untrusted host can make either call fail and leave the page shared. Both paths still free the page: the init error path with __free_page(), and kvm_arch_ptp_exit() after only a WARN_ON(). The page allocator can then hand a page the host can still access to an unrelated user. Leak the page in both cases instead, as was done for the same situation in commit b9fa16949d18 ("dma-direct: Leak pages on dma_set_decrypted() failure") and commit 03f5a999adba ("Drivers: hv: vmbus: Leak pages if set_memory_encrypted() fails"). Fixes: 6365ba64b4dbe ("ptp: kvm: Use decrypted memory in confidential guest on x86") Signed-off-by: Yuho Choi Link: https://patch.msgid.link/20261105164324.23501-2-oss.patchbox@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/ptp/ptp_kvm_x86.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/ptp/ptp_kvm_x86.c b/drivers/ptp/ptp_kvm_x86.c index 5e5b2ef785474..ab35b20dfb7df 100644 --- a/drivers/ptp/ptp_kvm_x86.c +++ b/drivers/ptp/ptp_kvm_x86.c @@ -36,7 +36,7 @@ int kvm_arch_ptp_init(void) clock_pair = page_address(p); ret = set_memory_decrypted((unsigned long)clock_pair, 1); if (ret) { - __free_page(p); + /* The page may be left shared, so leak it. */ clock_pair = NULL; goto nofree; } @@ -68,8 +68,9 @@ int kvm_arch_ptp_init(void) void kvm_arch_ptp_exit(void) { if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) { - WARN_ON(set_memory_encrypted((unsigned long)clock_pair, 1)); - free_page((unsigned long)clock_pair); + /* Leak the page if it cannot be made private again. */ + if (!WARN_ON(set_memory_encrypted((unsigned long)clock_pair, 1))) + free_page((unsigned long)clock_pair); clock_pair = NULL; } } -- 2.53.0