Linux virtualization list
 help / color / mirror / Atom feed
From: Showta Ishizaki <zakinko@snowrabbit.org>
To: "Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>,
	sashiko-reviews@lists.linux.dev
Cc: virtualization@lists.linux.dev, zakinko@snowrabbit.org
Subject: Re: [PATCH RFC net v8 4/6] net: resolve uncommon partial checksums at ingress
Date: Wed,  2 Dec 2026 12:06:38 +0900 (JST)	[thread overview]
Message-ID: <20261202.rfcv8-reply.4.zakinko@snowrabbit.org> (raw)
In-Reply-To: <sashiko-outbox-235877@kernel.org>

Thanks for the careful read on patch 4 -- both are real, and finding 1 was
the one I had underestimated until I measured it.

Finding 1 (has_eth taken from dev->type, which TUNSETLINK desyncs): fixed.
has_eth now also requires dev_has_header(skb->dev), so an IFF_TUN device
turned ARPHRD_ETHER by TUNSETLINK (which has no header-create op) is treated
as having no link-layer header, and virtio_net_l3_start() reads the L3 header
where packet_snd() actually put it.

I did not want to take the retention on faith, so I reproduced it. On a
TUNSETLINK'd tun I sent, through AF_PACKET + PACKET_VNET_HDR with
csum_start=34 and csum_offset=6, a frame that is a genuine IPv4/UDP datagram
at offset 0 but whose source-address bytes also read as a header when the
first 14 bytes are taken as Ethernet: src 8.0.69.1 makes bytes 12-13 read as
0x0800 and byte 14 as 0x45, and the UDP ports (0x4000, 0x4011) make the bytes
at offset 14 parse as an unfragmented IPv4/UDP header with its transport at
offset 34. A kprobe on __dev_queue_xmit printed skb->ip_summed (3 =
CHECKSUM_PARTIAL, 0 = NONE). On the series as-is (v8):

    csumprobe: crafted ip_summed=3 csum_start=50 csum_offset=6
    csumprobe: legit   ip_summed=0 csum_start=36 csum_offset=6

and with the has_eth fix (v9):

    csumprobe: crafted ip_summed=0 csum_start=50 csum_offset=6
    csumprobe: legit   ip_summed=3 csum_start=36 csum_offset=6

(csum_start is from skb->head, 16 bytes of headroom ahead of the real offsets
34 and 20.) So exactly as you describe: v8 retains CHECKSUM_PARTIAL on the
crafted frame with csum_start at offset 34, pointing into the payload rather
than the real UDP checksum at 26, and the mirror image shows the same desync
from the other side -- v8 wrongly resolves the plain legitimate frame because
it reads it against an Ethernet layout, while v9 keeps it offloaded. The fix
settles both.

My first attempt did not retain it, which is what sent me to build the frame
above: a crafted frame whose source address does not happen to read as 0x0800
fails virtio_net_l4_start() and is resolved on v8 too, so the retention needs
the header-shaped bytes you point at.

Finding 2 (skb->protocol set after validation): fixed. When
virtio_net_l3_start resolves the protocol from the header it now records it
into skb->protocol, so virtio_net_hdr_set_proto() can no longer override an
IPv6 frame with ETH_P_IP for GSO_UDP_L4. It needs a device with no
header_ops->parse_protocol (tun has one), so it is narrow, but the guard is
cheap and the gap was real.

For regression I reran the 35-case flow-match matrix (OVS 3.5.0): v9 rewrites
no matched header, identical to v8, so neither fix disturbs the common paths.

Showta

  reply	other threads:[~2026-12-02  3:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 16:06 [PATCH RFC net v8 0/6] more virtio-net csum hardening Showta Ishizaki
2026-11-25 16:06 ` [PATCH RFC net v8 1/6] net: account for ingress-resolved virtio net hdr state Showta Ishizaki
2026-11-25 16:06 ` [PATCH RFC net v8 2/6] um: vector: trim skbs before verifying the header Showta Ishizaki
2026-11-25 16:06 ` [PATCH RFC net v8 3/6] virtio_net: parse tunnel csum_start little-endian Showta Ishizaki
2026-11-25 16:06 ` [PATCH RFC net v8 4/6] net: resolve uncommon partial checksums at ingress Showta Ishizaki
2026-11-26 16:07   ` sashiko-bot
2026-12-02  3:06     ` Showta Ishizaki [this message]
2026-11-25 16:06 ` [PATCH RFC net v8 5/6] net: virtio: compute the outer checksum of non-GSO tunnel packets Showta Ishizaki
2026-11-25 16:06 ` [PATCH RFC net v8 6/6] net: add a sysctl to opt out of virtio net hdr checksum validation Showta Ishizaki
2026-11-26 16:07 ` [PATCH RFC net v8 0/6] more virtio-net csum hardening 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=20261202.rfcv8-reply.4.zakinko@snowrabbit.org \
    --to=zakinko@snowrabbit.org \
    --cc=eperezma@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox