From: Mark Syms <mark.syms@citrix.com>
To: jgross@suse.com, sstabellini@kernel.org,
oleksandr_tyshchenko@epam.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com
Cc: hawk@kernel.org, ast@kernel.org, daniel@iogearbox.net,
john.fastabend@gmail.com, sdf@fomichev.me,
netdev@vger.kernel.org, xen-devel@lists.xenproject.org,
bpf@vger.kernel.org, mark.syms@citrix.com,
stable@vger.kernel.org
Subject: [PATCH net] xen-netfront: unwind created queues when page_pool creation fails
Date: Wed, 25 Nov 2026 11:11:29 +0000 [thread overview]
Message-ID: <20261125111129.3109095-1-mark.syms@citrix.com> (raw)
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
reply other threads:[~2026-11-25 11:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125111129.3109095-1-mark.syms@citrix.com \
--to=mark.syms@citrix.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=jgross@suse.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oleksandr_tyshchenko@epam.com \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=sstabellini@kernel.org \
--cc=stable@vger.kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox