From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E7421D54D; Tue, 14 May 2024 11:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686410; cv=none; b=KMeRwGmXQJNKX1X2Ra5Xg1r3+GkpMb8Gx7huOicC6H9/tiZ5mc1UlT/mOmL8J9SQBw9he/iW6JkcxYQc2+XDiDffq5/6ye5zZXbfiWq9dBwGs/w3sprOE/ziNG3JkLJMuIy4CBofUOpDs8PCl4Tw3Ktrd/YXUaPRnOpPoGiluiY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686410; c=relaxed/simple; bh=yx5CiT6W9asF+YvOzQmpNh9aVnZakGwKIgB++bf7jmQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DRcAf22Y5kfIVWW0EqISzLlcYj5HtGaxRjoWFQmiPFFbpp9UFFOzW4c4sl2OF77JMIFlChJXe0RnwilfVf1Dy0ucXrbnnQr9096D11Qfz0UZAohsTo3ejxrCE7/0EPimnaML9E23xBRf7uGn03NJtmcLzYr4ooyr69PlpwD4Q/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SNkwUHkD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="SNkwUHkD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA781C2BD10; Tue, 14 May 2024 11:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1715686410; bh=yx5CiT6W9asF+YvOzQmpNh9aVnZakGwKIgB++bf7jmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SNkwUHkDWqinkEAa5UMiHfHgW/+tnDzbx3CbqF3Yzu4IX+spXIeRyvmDOvt0Clk0s dvrrNKCzRs/UyrZMibvFM95obM5HOl2ct6Zy5KjhEI7kw4Jvtujahn9l49EeCEcYVx Jrn8BcPOMiSCdxwd465cYzUBIuIp0Kp3/TtDuoEY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Kelley , Kuppuswamy Sathyanarayanan , "Kirill A. Shutemov" , Wei Liu , Sasha Levin Subject: [PATCH 6.1 129/236] Drivers: hv: vmbus: Dont free ring buffers that couldnt be re-encrypted Date: Tue, 14 May 2024 12:18:11 +0200 Message-ID: <20240514101025.268094442@linuxfoundation.org> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514101020.320785513@linuxfoundation.org> References: <20240514101020.320785513@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Kelley [ Upstream commit 30d18df6567be09c1433e81993e35e3da573ac48 ] In CoCo VMs it is possible for the untrusted host to cause set_memory_encrypted() or set_memory_decrypted() to fail such that an error is returned and the resulting memory is shared. Callers need to take care to handle these errors to avoid returning decrypted (shared) memory to the page allocator, which could lead to functional or security issues. The VMBus ring buffer code could free decrypted/shared pages if set_memory_decrypted() fails. Check the decrypted field in the struct vmbus_gpadl for the ring buffers to decide whether to free the memory. Signed-off-by: Michael Kelley Reviewed-by: Kuppuswamy Sathyanarayanan Acked-by: Kirill A. Shutemov Link: https://lore.kernel.org/r/20240311161558.1310-6-mhklinux@outlook.com Signed-off-by: Wei Liu Message-ID: <20240311161558.1310-6-mhklinux@outlook.com> Signed-off-by: Sasha Levin --- drivers/hv/channel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index bb5abdcda18f8..47e1bd8de9fcf 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -153,7 +153,9 @@ void vmbus_free_ring(struct vmbus_channel *channel) hv_ringbuffer_cleanup(&channel->inbound); if (channel->ringbuffer_page) { - __free_pages(channel->ringbuffer_page, + /* In a CoCo VM leak the memory if it didn't get re-encrypted */ + if (!channel->ringbuffer_gpadlhandle.decrypted) + __free_pages(channel->ringbuffer_page, get_order(channel->ringbuffer_pagecount << PAGE_SHIFT)); channel->ringbuffer_page = NULL; -- 2.43.0