Re: [PATCH net-next v5 2/9] virtio-net: zero the whole tx header
From: netdev-bot+sashiko
Date: Mon Nov 16 2026 - 08:57:30 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit fixes a real bug: virtio-net TX headers reach the
device with stale or uninitialised bytes.
- [Low] The commit message says the bytes the helper does not set "go to
the device as they were in skb->cb or the headroom", but it never says…
--
virtio-net: zero the whole tx header
This commit clears the whole negotiated virtio-net header in xmit_skb()
before virtio_net_hdr_tnl_from_skb() fills it in. Bytes past struct
virtio_net_hdr no longer carry stale skb->cb or headroom contents to the
device. The separate num_buffers assignment for mergeable rx buffers is
dropped because the memset covers it.
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index dd2c41ef6fbe7..4c740b403ad1e 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -3326,14 +3326,16 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb, bool orphan)
> else
> hdr = &skb_vnet_common_hdr(skb)->tnl_hdr;
>
> + /* Fields the helper below does not fill in must not carry stale
> + * skb->cb or headroom bytes to the device.
> + */
> + memset(hdr, 0, hdr_len);
> +
[Severity: Medium]
This fixes uninitialized bytes reaching the device. Should it carry a Fixes:
tag and go to net on its own, rather than as part of a net-next series?
Before this change, non-tunnel skbs only went through
virtio_net_hdr_from_skb(). That clears sizeof(struct virtio_net_hdr), which
is 10 bytes.
virtnet_probe() sets vi->hdr_len to 12 (VIRTIO_F_VERSION_1 or MRG_RXBUF), 20
(hash report) or 24 (UDP tunnel GSO). So bytes 10 through hdr_len - 1 went to
the device unchanged from skb->cb or the headroom.
The 24-byte layout and the current form of the num_buffers assignment come
from this commit, which is in currently maintained stable kernels:
Fixes: 56a06bd40fab ("virtio_net: enable gso over UDP tunnel support.")
The 12-byte and 20-byte cases are older, so their origin commits could be
named as well.
Without the tag, the fix only lives in a net-next feature series (RX
timestamp support). Would stable and distro kernels then keep sending up to
14 stale bytes per packet?
> if (virtio_net_hdr_tnl_from_skb(skb, hdr, vi->tx_tnl,
> virtio_is_little_endian(vi->vdev), 0,
> false, feature_hdrlen))
> return -EPROTO;
>
> - if (vi->mergeable_rx_bufs)
> - hdr->hash_hdr.hdr.num_buffers = 0;
> -
[Severity: Low]
The commit message says the remaining bytes "go to the device as they were
in skb->cb or the headroom". It does not say that this exposes kernel memory
to the device. Could the message state that?
In the can_push case of xmit_skb(), hdr points into the skb headroom:
if (can_push)
hdr = (struct virtio_net_hdr_v1_hash_tunnel *)(skb->data -
hdr_len);
The skb allocators don't zero the headroom, and nothing writes the bytes in
front of the Ethernet header. So up to 14 bytes of uninitialized slab
content per packet ended up in buffers the device can read. This matters
when the host or backend is not trusted, for example SEV-SNP/TDX guests or
VDUSE and vhost-user backends.
Also, the virtio spec requires the driver to set num_buffers to zero on
transmit, so a non-zero value there breaks the spec.
The XDP TX path in the same driver already zeroes the whole header in
__virtnet_xdp_xmit_one():
memset(hdr, 0, vi->hdr_len);
Without words like "info leak" or "uninitialized memory", might maintainers
and stable reviewers treat this patch as a cleanup?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-v6-7-topic-virtio-net-ptp-v5-0-7ab67b572f4f%40pengutronix.de