From: sashiko-bot@kernel.org
To: "Showta Ishizaki" <zakinko@snowrabbit.org>
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH RFC net v11 5/6] net: virtio: compute the outer checksum of non-GSO tunnel packets
Date: Sat, 05 Dec 2026 04:01:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-251042@kernel.org> (raw)
In-Reply-To: <20261204.rfcv11.99731.5.zakinko@snowrabbit.org>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] net: virtio: unchecked uh->len and LCO padding mismatch in
outer csum
- [Low] net: virtio: IPv6 outer UDP csum ignores active Routing Header
daddr
- [Low] net: virtio: lco_csum() miscomputes outer csum on odd inner_th -
outer_th
- [Low] net: virtio: redundant outer header parsing in
virtio_net_tnl_set_outer_csum()
--
commit 3a617a73c8dde395774db7194e8a070983df80c7
Author: Showta Ishizaki <zakinko@snowrabbit.org>
net: virtio: compute the outer checksum of non-GSO tunnel packets
This commit adds virtio_net_tnl_set_outer_csum() to compute the outer
UDP checksum for non-GSO tunnel packets with
VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM, either via local checksum offload
while CHECKSUM_PARTIAL or by summing the datagram in full after software
inner checksum completion.
> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index 714b20acd38f0..6fe0c59217175 100644
> --- a/include/linux/virtio_net.h
> +++ b/include/linux/virtio_net.h
[ ... ]
> @@ -553,6 +555,72 @@ virtio_net_tnl_offsets_ok(struct sk_buff *skb, bool has_eth, bool outer_isv6,
> return ip_proto == IPPROTO_UDP && outer_th == thoff;
> }
[ ... ]
> +static inline int
> +virtio_net_tnl_set_outer_csum(struct sk_buff *skb, bool has_eth,
> + bool outer_isv6, unsigned int outer_th)
> +{
> + unsigned int thoff;
> + struct udphdr *uh;
> + int ip_proto, nhoff;
> + __be16 proto;
> + __wsum csum;
> + int len, err;
> +
> + /* virtio_net_tnl_offsets_ok() has passed; this finds nhoff. */
> + if (!virtio_net_l3_start(skb, has_eth, &nhoff, &proto) ||
> + !virtio_net_l4_start(skb, nhoff, proto, &thoff, &ip_proto))
> + return -EINVAL;
[Severity: Low]
This isn't a bug, but virtio_net_tnl_offsets_ok() has already run both
virtio_net_l3_start() and virtio_net_l4_start() for this packet, and
thoff and ip_proto are unused here. Returning nhoff from
virtio_net_tnl_offsets_ok() and passing it in would avoid repeating the
outer header walk.
Similarly, virtio_net_hdr_tnl_to_skb() sets SKB_GSO_UDP_TUNNEL_CSUM or
SKB_GSO_UDP_TUNNEL in gso_type unconditionally and then immediately
clears them when !skb_is_gso(skb).
> +
> + err = skb_ensure_writable(skb, outer_th + sizeof(*uh));
> + if (err)
> + return err;
> +
> + uh = (struct udphdr *)(skb->data + outer_th);
> + len = ntohs(uh->len);
> + uh->check = 0;
> + if (skb->ip_summed == CHECKSUM_PARTIAL) {
> + csum = lco_csum(skb);
[Severity: Low]
Can lco_csum() miscompute the outer checksum when inner_th - outer_th is
odd?
virtio_net_hdr_tnl_to_skb() allows an odd inner_nh_offset, which makes
skb_checksum_start(skb) - skb_transport_header(skb) odd. lco_csum()
passes that length to csum_partial(), which requires even lengths for
non-final chunks and otherwise folds the inner checksum complement at
the wrong byte parity.
> + } else {
> + /* Sum the datagram alone: uh->len, not skb->len - outer_th,
> + * which also counts non-zero Ethernet padding and so
> + * miscomputes the outer checksum. len is from the frame,
> + * so bound it before reading that many bytes.
> + */
> + if (len < sizeof(*uh) || len > skb->len - outer_th)
> + return -EINVAL;
> + csum = skb_checksum(skb, outer_th, len, 0);
> + }
[Severity: Medium]
Should the uh->len bounds check also run on the CHECKSUM_PARTIAL path,
before uh->check is cleared? An untrusted frame with an invalid uh->len
currently bypasses the check and gets a bogus outer UDP checksum instead
of -EINVAL.
Also, when a small tunnel packet has non-zero Ethernet padding
(skb->len > outer_th + len), does lco_csum() produce the wrong outer
checksum? skb_checksum_help() and TX offload sum through skb->len, so
the padding breaks LCO cancellation and causes receiver drops.
Validating uh->len before mutating uh->check and either requiring
outer_th + len == skb->len for LCO or falling back to completing the
inner checksum and summing [outer_th, outer_th + len) would handle both
cases.
> +
> + if (outer_isv6) {
> + const struct ipv6hdr *ip6h = (void *)(skb->data + nhoff);
> +
> + uh->check = udp_v6_check(len, &ip6h->saddr, &ip6h->daddr,
> + csum);
> + } else {
[Severity: Low]
Does udp_v6_check() use the wrong destination address when the outer
IPv6 packet carries an active Routing Header (segments_left > 0)?
virtio_net_l4_start() calls ipv6_find_hdr() with target -1, which walks
past NEXTHDR_ROUTING regardless of segments_left. Using ip6h->daddr
instead of the final destination address from the Routing Header
violates RFC 8200 Section 8.1 and causes drops at the final destination.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204.rfcv11.99731.0.zakinko@snowrabbit.org?part=5
next prev parent reply other threads:[~2026-12-05 4:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 4:01 [PATCH RFC net v11 0/6] more virtio-net csum hardening Showta Ishizaki
2026-12-04 4:01 ` [PATCH RFC net v11 6/6] net: add a sysctl to opt out of virtio net hdr checksum validation Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot
2026-12-04 4:01 ` [PATCH RFC net v11 5/6] net: virtio: compute the outer checksum of non-GSO tunnel packets Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot [this message]
2026-12-04 4:01 ` [PATCH RFC net v11 2/6] um: vector: trim skbs before verifying the header Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot
2026-12-04 4:01 ` [PATCH RFC net v11 1/6] net: account for ingress-resolved virtio net hdr state Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot
2026-12-04 4:01 ` [PATCH RFC net v11 4/6] net: resolve uncommon partial checksums at ingress Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot
2026-12-04 4:01 ` [PATCH RFC net v11 3/6] virtio_net: parse tunnel csum_start little-endian Showta Ishizaki
2026-12-04 4:06 ` [PATCH RFC net v11 0/6] more virtio-net csum hardening netdev-bot+sinfo
2026-12-05 4:01 ` 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-251042@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=zakinko@snowrabbit.org \
/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.