* [PATCH net] xen-netfront: unwind created queues when page_pool creation fails
@ 2026-11-25 11:11 Mark Syms
2026-12-03 10:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Mark Syms @ 2026-11-25 11:11 UTC (permalink / raw)
To: jgross, sstabellini, oleksandr_tyshchenko, andrew+netdev, davem,
edumazet, kuba, pabeni
Cc: hawk, ast, daniel, john.fastabend, sdf, netdev, xen-devel, bpf,
mark.syms, stable
If xennet_create_page_pool() fails for any queue after the first,
xennet_create_queues() returns without undoing the queues it has
already set up, and talk_to_netback() then frees info->queues. The
NAPI instances of those queues stay on the netdev's napi_list,
pointing into the freed array, and their page pools, XDP rxq
registrations and grant references leak, as do the grant references
of the queue that failed. Reaching this needs an allocation failure
in page_pool_create() or the XDP rxq registration during connect or
resume.
Release the failing queue's grant references and unwind every queue
created before it inside xennet_create_queues(). talk_to_netback()
still frees the array; on this path neither
xennet_disconnect_backend() nor xennet_destroy_queues() sees the
queues, so nothing is released twice.
sashiko-bot found the bug while reviewing an unrelated netfront fix.
The patch builds without warnings at W=1 on net (gcc 12.4) and passes
checkpatch --strict. The failure path was not exercised: no fault
injection or boot test was run.
An AI coding assistant (Claude Code) was used to confirm the report,
write the fix and draft this changelog.
Link: https://lore.kernel.org/r/sashiko-outbox-232996@kernel.org
Fixes: 6c5aa6fc4def ("xen networking: add basic XDP support for xen-netfront")
Cc: stable@vger.kernel.org
Signed-off-by: Mark Syms <mark.syms@citrix.com>
---
drivers/net/xen-netfront.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index fdcb91042f29..9abae76871f3 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -2244,8 +2244,9 @@ static int xennet_create_queues(struct netfront_info *info,
ret = xennet_create_page_pool(queue);
if (ret < 0) {
dev_err(&info->xbdev->dev, "can't allocate page pool\n");
- *num_queues = i;
- return ret;
+ gnttab_free_grant_references(queue->gref_tx_head);
+ gnttab_free_grant_references(queue->gref_rx_head);
+ goto err_unwind;
}
netif_napi_add(queue->info->netdev, &queue->napi, xennet_poll);
@@ -2260,6 +2261,21 @@ static int xennet_create_queues(struct netfront_info *info,
return -EINVAL;
}
return 0;
+
+err_unwind:
+ while (i--) {
+ struct netfront_queue *queue = &info->queues[i];
+
+ if (netif_running(info->netdev))
+ napi_disable(&queue->napi);
+ netif_napi_del(&queue->napi);
+ xdp_rxq_info_unreg(&queue->xdp_rxq);
+ page_pool_destroy(queue->page_pool);
+ gnttab_free_grant_references(queue->gref_tx_head);
+ gnttab_free_grant_references(queue->gref_rx_head);
+ }
+ *num_queues = 0;
+ return ret;
}
/* Common code used when first setting up, and when resuming. */
--
2.56.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] xen-netfront: unwind created queues when page_pool creation fails
2026-11-25 11:11 [PATCH net] xen-netfront: unwind created queues when page_pool creation fails Mark Syms
@ 2026-12-03 10:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-12-03 10:00 UTC (permalink / raw)
To: Mark Syms
Cc: jgross, sstabellini, oleksandr_tyshchenko, andrew+netdev, davem,
edumazet, kuba, pabeni, hawk, ast, daniel, john.fastabend, sdf,
netdev, xen-devel, bpf, stable
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Wed, 25 Nov 2026 11:11:29 +0000 you wrote:
> If xennet_create_page_pool() fails for any queue after the first,
> xennet_create_queues() returns without undoing the queues it has
> already set up, and talk_to_netback() then frees info->queues. The
> NAPI instances of those queues stay on the netdev's napi_list,
> pointing into the freed array, and their page pools, XDP rxq
> registrations and grant references leak, as do the grant references
> of the queue that failed. Reaching this needs an allocation failure
> in page_pool_create() or the XDP rxq registration during connect or
> resume.
>
> [...]
Here is the summary with links:
- [net] xen-netfront: unwind created queues when page_pool creation fails
https://git.kernel.org/netdev/net-next/c/21e3bc509753
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 10:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 11:11 [PATCH net] xen-netfront: unwind created queues when page_pool creation fails Mark Syms
2026-12-03 10:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox