From: sashiko-bot@kernel.org
To: "Longjun Tang" <lange_tang@163.com>
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v2 3/3] virtio_net: add stalls per-queue statistic
Date: Sat, 21 Nov 2026 07:18:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-226758@kernel.org> (raw)
In-Reply-To: <20261120071826.198604-4-lange_tang@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] virtio_net: race between virtnet_rx_watchdog() and RX queue
pause/reset
--
commit fd9c9353e0dbe0759e73fd91a8963232b76ecc1c
Author: Longjun Tang <tanglongjun@kylinos.cn>
virtio_net: add stalls per-queue statistic
This commit adds a per-queue RX stalls statistic to virtio_net and exposes
it via ethtool when NAPI poll recovers a stalled RX queue.
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7f21fe4f96a2b..0b95fa10734d2 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
[ ... ]
> @@ -3005,6 +3007,12 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
> u64_stats_add(item, u64_stats_read(src));
> }
>
> + /* Count a stall recovered by this poll. */
> + if (rq->watchdog.stalled) {
> + u64_stats_inc(&rq->stats.stalls);
> + rq->watchdog.stalled = false;
> + }
[Severity: Medium]
Can virtnet_rx_watchdog() race with an RX queue resize or reset while the
interface is up, causing a use-after-free on the vring and false
rq->stats.stalls increments?
Commit "virtio_net: introduce an RX queue watchdog for stuck detection"
starts vi->rx_watchdog in virtnet_open() and only stops it in
virtnet_close(). When virtnet_rx_resize() or virtnet_rq_bind_xsk_pool()
pauses an active RX queue via virtnet_rx_pause(), it disables NAPI and DIM
but does not stop or synchronize with vi->rx_watchdog:
CPU0 CPU1 (<softirq>)
virtnet_rx_resize()
virtnet_rx_pause(vi, rq)
virtqueue_resize(rq->vq, ...)
virtnet_rx_watchdog()
last_used =
virtqueue_get_last_used_idx(...)
vring_free(&vq->vq)
virtqueue_poll(rq->vq, last_used)
<-- use-after-free
In addition, virtqueue_resize() and virtqueue_reset() reset
vq->last_used_idx, but neither path calls
virtnet_rx_watchdog_init_queue(rq). Any stale rq->watchdog.last_used or
rq->watchdog.stalled state persists across the reset and causes
virtnet_receive() to falsely increment rq->stats.stalls after the queue is
resumed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120071826.198604-1-lange_tang@163.com?part=3
next prev parent reply other threads:[~2026-11-21 7:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:18 [PATCH v2 0/3] virtio_net: introduce an RX queue watchdog for stuck detection Longjun Tang
2026-11-20 7:18 ` [PATCH v2 1/3] virtio: add virtqueue_get_last_used_idx() helper Longjun Tang
2026-11-20 17:43 ` Michael S. Tsirkin
2026-11-21 7:18 ` sashiko-bot
2026-11-20 7:18 ` [PATCH v2 2/3] virtio_net: introduce an RX queue watchdog for stuck detection Longjun Tang
2026-11-21 7:18 ` sashiko-bot
2026-11-20 7:18 ` [PATCH v2 3/3] virtio_net: add stalls per-queue statistic Longjun Tang
2026-11-21 7:18 ` sashiko-bot [this message]
2026-11-20 17:45 ` [PATCH v2 0/3] virtio_net: introduce an RX queue watchdog for stuck detection Michael S. Tsirkin
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-226758@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=eperezma@redhat.com \
--cc=lange_tang@163.com \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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.