All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Haishuang Yan" <yanhaishuang@cmss.chinamobile.com>
Cc: virtualization@lists.linux.dev,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH net v2 2/3] virtio_net: Disable AF_XDP pools on queues above curr_queue_pairs
Date: Mon, 09 Nov 2026 11:39:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-204884@kernel.org> (raw)
In-Reply-To: <20261108193845.73621-3-yanhaishuang@cmss.chinamobile.com>

> With an XDP program attached, virtnet_xdp_set() adds nr_cpu_ids queue
> pairs for XDP_TX and raises curr_queue_pairs and real_num_rx_queues to
> match. virtnet_xsk_pool_enable() accepts any queue below
> curr_queue_pairs, so an AF_XDP zero-copy socket can be bound to one of
> them.
> 
> When the program is removed, the queue count goes down again while the
> pool stays bound to the driver. When the socket is closed afterwards,
> virtnet_xsk_pool_disable() rejects the queue with -EINVAL, and the core
> frees the pool anyway:
> 
>   WARNING: net/xdp/xsk_buff_pool.c:160 at xp_disable_drv_zc+0x1ee/0x260
>   BUG: KASAN: slab-use-after-free in xp_alloc_batch+0x930/0xb40
>   Read of size 8 at addr ffff8880028eb400 by task ksoftirqd/0/14
>    xp_alloc_batch+0x930/0xb40
>    try_fill_recv+0xb27/0x26e0
> 
> as rq->xsk_pool still points to it and the queue is refilled from it.
> 
> Removing XDP must not fail, so let virtnet_xsk_pool_disable() accept
> any queue the driver has, below max_queue_pairs. The receive and send
> queues above curr_queue_pairs still exist, so they are unbound as usual.
> 
> This was pointed out by the Sashiko review of v1 of this series, and
> reproduced in QEMU by binding a socket to an XDP queue, removing XDP
> and closing the socket.
> 
> Fixes: 09d2b3182c8e ("virtio_net: xsk: bind/unbind xsk for rx")
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261108193845.73621-1-yanhaishuang@cmss.chinamobile.com?part=2


  reply	other threads:[~2026-11-09 11:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08 19:38 [PATCH net v2 0/3] virtio_net: AF_XDP zero-copy fixes for arm64 and suspend Haishuang Yan
2026-11-08 19:38 ` [PATCH net v2 1/3] virtio_net: Don't DMA map the kernel image for the AF_XDP TX header Haishuang Yan
2026-11-09 11:39   ` sashiko-bot
2026-11-08 19:38 ` [PATCH net v2 2/3] virtio_net: Disable AF_XDP pools on queues above curr_queue_pairs Haishuang Yan
2026-11-09 11:39   ` sashiko-bot [this message]
2026-11-09 12:34   ` netdev-bot+sashiko
2026-11-10 11:20     ` Haishuang Yan
2026-11-08 19:38 ` [PATCH net v2 3/3] virtio_net: Keep AF_XDP zero-copy pools bound across suspend Haishuang Yan
2026-11-09 11:39   ` sashiko-bot
2026-11-09 12:34   ` netdev-bot+sashiko
2026-11-10 11:21     ` Haishuang Yan

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=sashiko-outbox-204884@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    --cc=yanhaishuang@cmss.chinamobile.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.