[PATCH net 2/2] hv_netvsc: Leak send/recv buffers if GPADL teardown fails
From: Michael Kelley
Date: Thu Sep 03 2026 - 13:30:54 EST
If GPADL teardown fails for the send or receive buffers, the Hyper-V
host retains access to the buffers and might continue to access them.
Per the code comments, the intent is to be safe by leaking the buffers
instead of freeing them.
The intended behavior existed prior to commit 02400fcee254 ("hv_netvsc:
use RCU to fix concurrent rx and queue changes") because freeing
the buffers was done in the same function as the GPADL teardown.
The "return" statement in the error path effectively skipped freeing
the memory. But commit 02400fcee254 moved the freeing to a separate
function that is called later. It has no knowledge of the GPADL teardown
error, and so frees the memory regardless.
Fix this by calling vmbus_leak_buffer() if the respective GPADL
teardown fails. The later call to vmbus_free_buffer() then skips
freeing of the actual buffer, including any re-encryption required
in a CoCo VM.
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/linux-hyperv/20260731201210.3653C1F00AC4@xxxxxxxxxxxxxxx/
Fixes: 02400fcee254 ("hv_netvsc: use RCU to fix concurrent rx and queue changes")
Signed-off-by: Michael Kelley <mhklinux@xxxxxxxxxxx>
---
drivers/net/hyperv/netvsc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 5cd084e5696c..449dc928cc44 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -316,6 +316,9 @@ static void netvsc_teardown_recv_gpadl(struct hv_device *device,
* rather than continue and a bugchk
*/
if (ret != 0) {
+ vmbus_leak_buffer(&net_device->recv_buf,
+ &net_device->recv_buf_chunks,
+ &net_device->recv_buf_chunk_cnt);
netdev_err(ndev,
"unable to teardown receive buffer's gpadl\n");
return;
@@ -337,6 +340,9 @@ static void netvsc_teardown_send_gpadl(struct hv_device *device,
* rather than continue and a bugchk
*/
if (ret != 0) {
+ vmbus_leak_buffer(&net_device->send_buf,
+ &net_device->send_buf_chunks,
+ &net_device->send_buf_chunk_cnt);
netdev_err(ndev,
"unable to teardown send buffer's gpadl\n");
return;
--
2.25.1