All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lianjie Wang" <lian@is.s.u-tokyo.ac.jp>
Cc: virtualization@lists.linux.dev,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH net v3 2/4] virtio_net: zero the stats reply buffer
Date: Mon, 16 Nov 2026 09:42:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-216627@kernel.org> (raw)
In-Reply-To: <20261116092445.3391334-3-lian@is.s.u-tokyo.ac.jp>

> virtnet_get_hw_stats() allocates the reply buffer of the device
> statistics command with kmalloc(), and __virtnet_get_hw_stats() parses
> the whole buffer. When the device writes less than the buffer holds,
> stale heap bytes are reported as counters through ethtool -S and the
> per-queue netlink statistics.
> 
> Allocate the buffer with kzalloc(), so that the counters the device
> didn't write are zeroed. An unwritten record header then has size 0, so
> reject it when walking on that header to avoid an infinite loop.
> 
> The used length cannot replace the zeroing here, since the device can
> also report a larger value than it wrote.
> 
> Claude Opus 5.5 was used to audit the driver and draft this patch. To
> reproduce, the virtio-net device in QEMU was modified to offer device
> statistics and to leave the counters of a receive record unwritten. On
> an unmodified kernel, ethtool -S reported kernel pointers as rx0
> counters. With this patch, the counters are zeroed, and a reply with
> missing records or a record of size 0 is rejected. The
> drivers/net/stats.py selftest passes when the device answers with
> well-formed records.
> 
> Reported-by: Michael Bommarito <michael.bommarito@gmail.com>
> Link: https://lore.kernel.org/all/20260711150754.2918392-1-michael.bommarito@gmail.com/
> Reported-by: Jakub Kicinski <kuba@kernel.org>
> Link: https://lore.kernel.org/all/20261110001659.1654289-2-kuba@kernel.org/
> Fixes: 941168f8b40e ("virtio_net: support device stats")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116092445.3391334-1-lian@is.s.u-tokyo.ac.jp?part=2


  reply	other threads:[~2026-11-16  9:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  9:24 [PATCH net v3 0/4] virtio_net: fix out-of-bounds accesses and a heap info leak via the device stats reply Lianjie Wang
2026-11-16  9:24 ` [PATCH net v3 1/4] virtio_net: reject stats replies for queues outside the request Lianjie Wang
2026-11-16  9:42   ` sashiko-bot
2026-11-16  9:24 ` [PATCH net v3 2/4] virtio_net: zero the stats reply buffer Lianjie Wang
2026-11-16  9:42   ` sashiko-bot [this message]
2026-11-16  9:24 ` [PATCH net v3 3/4] virtio_net: keep reads of stats records within the " Lianjie Wang
2026-11-16  9:42   ` sashiko-bot
2026-11-16  9:24 ` [PATCH net v3 4/4] virtio_net: report a failed stats command as an error Lianjie Wang
2026-11-16  9:42   ` sashiko-bot

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-216627@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=lian@is.s.u-tokyo.ac.jp \
    --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.