From: sashiko-bot@kernel.org
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtualization@lists.linux.dev, "Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH net v3 6/8] net: add a sysctl to opt out of virtio net hdr checksum validation
Date: Tue, 20 Oct 2026 12:04:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-178922@kernel.org> (raw)
In-Reply-To: <6f23c55c6eba3e3ec6b2c7e3a80728a326ed58af.1792411304.git.mst@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: virtio_net_csum_partial_ok() fails to bypass virtio_net_l3_start()
--
commit 559fb10ce506a1c7276bf12adfdeed16a12a4f0c
Author: Michael S. Tsirkin <mst@redhat.com>
net: add a sysctl to opt out of virtio net hdr checksum validation
This commit adds a per-netns sysctl net.core.virtio_net_hdr_csum_check
guarded by a static key to allow opting out of ingress virtio_net_hdr
checksum metadata validation.
> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index 97b554ef7123f..25aa95c11e31a 100644
> --- a/include/linux/virtio_net.h
> +++ b/include/linux/virtio_net.h
[ ... ]
> @@ -179,6 +193,12 @@ virtio_net_csum_partial_ok_at_offset(struct sk_buff *skb, u8 hdr_gso_type,
> unsigned int thoff;
> int ip_proto;
>
> + /* Failsafe: a namespace opted out of the validation,
> + * trust the checksum metadata as before.
> + */
> + if (virtio_net_hdr_csum_check_disabled(skb))
> + return true;
> +
> if (!virtio_net_l4_start(skb, nhoff, proto, &thoff, &ip_proto))
> return false;
>
> @@ -516,6 +536,9 @@ virtio_net_tnl_offsets_ok(struct sk_buff *skb, bool outer_isv6,
> unsigned int thoff;
> int ip_proto;
>
> + if (virtio_net_hdr_csum_check_disabled(skb))
> + return true;
> +
> if (!virtio_net_l3_start(skb, &nhoff, &proto))
> return false;
> if (outer_isv6 != (proto == htons(ETH_P_IPV6)))
[Severity: Medium]
In virtio_net_tnl_offsets_ok(), virtio_net_hdr_csum_check_disabled(skb) is
checked before calling virtio_net_l3_start(). However, in the non-tunnel
path, virtio_net_hdr_to_skb() calls virtio_net_csum_partial_ok(), which
calls virtio_net_l3_start() before reaching the check in
virtio_net_csum_partial_ok_at_offset():
include/linux/virtio_net.h:virtio_net_csum_partial_ok() {
int nhoff;
__be16 proto;
if (!virtio_net_l3_start(skb, &nhoff, &proto))
return false;
return virtio_net_csum_partial_ok_at_offset(skb, hdr_gso_type, nhoff,
proto);
}
When net.core.virtio_net_hdr_csum_check is set to 0 and a packet with
VIRTIO_NET_HDR_F_NEEDS_CSUM enters virtio_net_hdr_to_skb(),
virtio_net_l3_start() still runs pskb_may_pull() and __vlan_get_protocol()
to compute nhoff and proto, which virtio_net_csum_partial_ok_at_offset()
then immediately discards.
Furthermore, if virtio_net_l3_start() returns false (for example, when
__vlan_get_protocol() returns 0 on VLAN tags exceeding VLAN_MAX_DEPTH, or
on a non-ARPHRD_ETHER device where skb_network_offset(skb) is unset or out
of bounds), virtio_net_csum_partial_ok() returns false without consulting
virtio_net_hdr_csum_check_disabled(skb). virtio_net_hdr_to_skb() then falls
through to virtio_net_resolve_csum_partial_mismatch(), dropping GSO packets
or completing non-GSO checksums in software despite the sysctl opt-out.
Should virtio_net_csum_partial_ok() check
virtio_net_hdr_csum_check_disabled(skb) before calling
virtio_net_l3_start()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792411304.git.mst@redhat.com?part=6
next prev parent reply other threads:[~2026-10-20 12:04 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 12:03 [PATCH net v3 0/8] more virtio-net csum hardening Michael S. Tsirkin
2026-10-19 12:03 ` [PATCH net v3 1/8] net: account for ingress-resolved virtio net hdr state Michael S. Tsirkin
2026-10-20 12:03 ` sashiko-bot
2026-10-20 19:27 ` Willem de Bruijn
2026-10-20 19:38 ` Michael S. Tsirkin
2026-10-20 20:02 ` Willem de Bruijn
2026-10-20 20:09 ` Michael S. Tsirkin
2026-10-19 12:03 ` [PATCH net v3 2/8] um: vector: honor virtio net hdr conversion failures Michael S. Tsirkin
2026-10-20 12:03 ` sashiko-bot
2026-10-20 19:28 ` Willem de Bruijn
2026-10-19 12:03 ` [PATCH net v3 3/8] um: vector: trim skbs before verifying the header Michael S. Tsirkin
2026-10-20 12:04 ` sashiko-bot
2026-10-19 12:03 ` [PATCH net v3 4/8] virtio_net: parse tunnel csum_start little-endian Michael S. Tsirkin
2026-10-20 12:04 ` sashiko-bot
2026-10-19 12:03 ` [PATCH net v3 5/8] net: resolve uncommon partial checksums at ingress Michael S. Tsirkin
2026-10-20 12:04 ` sashiko-bot
2026-10-20 19:44 ` Willem de Bruijn
2026-10-20 21:49 ` Michael S. Tsirkin
2026-10-21 0:05 ` Willem de Bruijn
2026-10-19 12:03 ` [PATCH net v3 6/8] net: add a sysctl to opt out of virtio net hdr checksum validation Michael S. Tsirkin
2026-10-19 14:19 ` Björn Töpel
2026-10-20 14:04 ` Michael S. Tsirkin
2026-10-20 12:04 ` sashiko-bot [this message]
2026-10-20 19:54 ` Willem de Bruijn
2026-10-20 20:01 ` Michael S. Tsirkin
2026-10-20 20:19 ` Willem de Bruijn
2026-10-20 20:22 ` Michael S. Tsirkin
2026-10-20 23:12 ` Willem de Bruijn
2026-10-20 23:21 ` Michael S. Tsirkin
2026-10-20 20:56 ` Michael S. Tsirkin
2026-10-20 23:13 ` Willem de Bruijn
2026-10-20 23:20 ` Michael S. Tsirkin
2026-10-19 12:03 ` [PATCH net v3 7/8] net: add ip4_parse() Michael S. Tsirkin
2026-10-20 12:04 ` sashiko-bot
2026-10-19 12:03 ` [PATCH net v3 8/8] virtio_net: cleanup protocol calculation Michael S. Tsirkin
2026-10-20 12:04 ` sashiko-bot
2026-10-19 12:09 ` [PATCH net v3 0/8] more virtio-net csum hardening netdev-bot+sinfo
2026-10-19 12:21 ` Michael S. Tsirkin
2026-10-19 16:51 ` Chris Arges
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-178922@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 \
/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