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 1351254903; Tue, 14 May 2024 10:38:44 +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=1715683124; cv=none; b=HQh1ccV8c+2sND/sTGsnEO6q3Objoahs0ZZVQ7dILJwqIlpV1tOVDxZK+soefbe8YYCHO/eVAmRcq6NXqmk11+rPvahAJb57wpbgDD7739/ZV60GEpcImdUFSjSnB6rHVgJaSa71GW5Oq7r+Mn4XYPR4b9isog6JQLiNOtHem9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715683124; c=relaxed/simple; bh=ji2txronKhWtK1uw5ez+a1oVKIzSomwP0K8zr3u6zvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUCWT9oxWrNQ5B7GzqzCjYvjHwYGlj8QpEOegsTVqUxn4z8pZVN/r1LK787etYpNzoqIApLVYOcDzA/KdvVabfLOyFbVY3QcAUJBsUgTn9ayyASKQU//i8GIt92yobXtD/0QAE0wLiZeSyeqGRXzAewR407e6hiWs5LhAdeWbak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fmeDZHHy; 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="fmeDZHHy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DB21C32781; Tue, 14 May 2024 10:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1715683123; bh=ji2txronKhWtK1uw5ez+a1oVKIzSomwP0K8zr3u6zvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fmeDZHHyZ3RGiLfc4dQItwQMcPUCSTI4LnM1Lxf+ZCrsrAWVdR/MQvgTWdCpHTT/L Q1zmlURPoy/h+6t89irQG8CKrAA8gq7VFKo9WWK+mAAzGrGVa8HRbKBxUk1CnbiACD n7+sskLEgLwUvJJB0Yx7WBOn3rUptGF9ArLqvB1c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rick Edgecombe , Michael Kelley , Kuppuswamy Sathyanarayanan , "Kirill A. Shutemov" , Wei Liu , Sasha Levin Subject: [PATCH 6.8 170/336] hv_netvsc: Dont free decrypted memory Date: Tue, 14 May 2024 12:16:14 +0200 Message-ID: <20240514101045.021202011@linuxfoundation.org> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514101038.595152603@linuxfoundation.org> References: <20240514101038.595152603@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.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rick Edgecombe [ Upstream commit bbf9ac34677b57506a13682b31a2a718934c0e31 ] 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 netvsc driver could free decrypted/shared pages if set_memory_decrypted() fails. Check the decrypted field in the gpadl to decide whether to free the memory. Signed-off-by: Rick Edgecombe Signed-off-by: Michael Kelley Reviewed-by: Kuppuswamy Sathyanarayanan Acked-by: Kirill A. Shutemov Link: https://lore.kernel.org/r/20240311161558.1310-4-mhklinux@outlook.com Signed-off-by: Wei Liu Message-ID: <20240311161558.1310-4-mhklinux@outlook.com> Signed-off-by: Sasha Levin --- drivers/net/hyperv/netvsc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index a6fcbda64ecc6..2b6ec979a62f2 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -154,8 +154,11 @@ static void free_netvsc_device(struct rcu_head *head) int i; kfree(nvdev->extension); - vfree(nvdev->recv_buf); - vfree(nvdev->send_buf); + + if (!nvdev->recv_buf_gpadl_handle.decrypted) + vfree(nvdev->recv_buf); + if (!nvdev->send_buf_gpadl_handle.decrypted) + vfree(nvdev->send_buf); bitmap_free(nvdev->send_section_map); for (i = 0; i < VRSS_CHANNEL_MAX; i++) { -- 2.43.0