From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: "Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
"Chris Arges" <carges@cloudflare.com>,
"Björn Töpel" <bjorn@kernel.org>, "Phil Sutter" <phil@nwl.cc>,
"Jason Wang" <jasowangio@gmail.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
netdev@vger.kernel.org, virtualization@lists.linux.dev,
"Max Krasnyansky" <maxk@qualcomm.com>,
"Rusty Russell" <rusty@rustcorp.com.au>
Subject: Re: [PATCH net v6 0/5] more virtio-net csum hardening
Date: Sun, 25 Oct 2026 09:50:24 -0400 [thread overview]
Message-ID: <20261025094449-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <cover.1792768096.git.mst@redhat.com>
On Fri, Oct 23, 2026 at 11:09:17AM -0400, Michael S. Tsirkin wrote:
>
> Okay this seems to be converging.... But sashiko did find some issues I
> thought are best fixed. Specifically I thought of a better way to handle
> short gso in a tunnel - just clear tunnel gso! As a side effect we now
> fix up the checksum for these dodgy packets like we did before, instead
> of a drop. Good. And more false positives that prompted me to write a
> bit more comments. So here goes.
>
> Apologies for reposting so frequently, I know netdev bot will be unhappy
> with that. But Paulos's report made a lot of publicity, there is a lot
> of people looking into this, so I feel there's value in defending
> against all this class of issues sooner rather than later.
>
> The issues were mostly found by code inspection, but all reproduced by
> me in a VM.
Ok, I looked at netdev bot review, and there's another issue.
If a tunnel inner packet happens to have a valid header at
inner_nh_offset, it will pass all checks, but the transport header can
in fact overlap e.g. the real TCP header and checksum will overwrite
that.
> ------
>
> As reported first by Paulos Yibelo <habte.yibelo@gmail.com> (after which
> others, credited below, found more ways the bug can affect users):
>
> allowing untrusted hardware to specify csum start/offset for
> CHECKSUM_PARTIAL was not a good idea, because, if it edits the packet
> outside the actual checksum, and depending on the setup, the networking
> stack could be looking at the packet both before and after the edit, and
> seeing different results.
>
> Previously, commit 6785011f8b16 ("ipv4: validate checksum_start before
> completing checksum") validated all known instances where this
> causes the most grief, but the real fix is to make sure
> that either only actual checksum fields are ever edited,
> or the checksum is completed before the net stack looks at it,
> so it is always consistent.
>
>
> This basically goes back to
> what we did before f43798c27684 ("tun: Allow GSO using virtio_net_hdr"),
> except in a narrow list of specified known good cases.
>
>
> Summary of the patchset:
>
> These are probabably net material (and seem to be too big for stable,
> or I would recommend backporting there, too):
>
> net: account for ingress-resolved virtio net hdr state
> - accounting, not the fix itself, dependency of the fix
> um: vector: trim skbs before verifying the header
> - fixes the um receive path: without it the checksum would be
> completed over the unreceived tail of the buffer
> virtio_net: parse tunnel csum_start little-endian
> - bugfix, a dependency of validating the header
> net: resolve uncommon partial checksums at ingress
> - fix itself
> net: add a sysctl to opt out of virtio net hdr checksum validation
> - reducing risk of the fix by adding a sysctl to disable it
>
> These are cleanups, can be deferred to net-next, too:
>
> net: add ip4_parse()
>
> Fixes: f43798c27684 ("tun: Allow GSO using virtio_net_hdr")
>
> Changes since v1:
> - reorder patches to fix bisectability, addressing
> a comment by Björn Töpel.
> - code refactoring, different patch splitup,
> a sysctl knob to disable as suggested by Willem de Bruijn.
> - fix a bunch of minor issues spotted by LLMs
>
>
> Changes since v2:
>
> virtio_net: parse tunnel csum_start little-endian
> - new patch. correctly parsing the header is a dependency
> of validating it, otherwise i do not know what to validate
>
> net: account for ingress-resolved virtio net hdr state
> - make rx_csum_sw counter 64 bit so it won't wrap
> (spotted by LLM review)
>
> net: resolve uncommon partial checksums at ingress
> - tunnel fixes to bugs noticed by Willem de Bruijn and
> Chris Arges
> - restore the csum_offset checks as suggested by Willem
>
> net: add a sysctl to opt out of virtio net hdr checksum validation
> - the knob is no longer writable by root inside a user
> namespace: changing it now requires capable(CAP_NET_ADMIN)
> suggested by Willem de Bruijn
>
> net: add ip4_parse()
> - comment converted to kernel-doc format (Willem de Bruijn)
>
> um: vector: trim skbs before verifying the header
> - new patch, found by code review
>
>
> Changes since v3:
>
> net: account for ingress-resolved virtio net hdr state
> - um: vector: honor virtio net hdr conversion failures
> folded in (Björn Töpel)
> - count on tap and virtio_net, too (Willem de Bruijn)
>
> net: resolve uncommon partial checksums at ingress
> - walk the frame on loopback, too: loopback_xmit() runs
> eth_type_trans() on it (Willem de Bruijn)
> - return the mismatch handling directly, GSO is implied in
> the tunnel path so drop there outright, and fold the helper
> into its one remaining caller (Willem de Bruijn)
> - read the IP version through struct iphdr (Willem de Bruijn)
> - document the ipv6_find_hdr() flags choice
>
> net: add a sysctl to opt out of virtio net hdr checksum validation
> - renamed to virtio_net_hdr_validate, in case more validation
> is gated by the same knob later (Willem de Bruijn)
> - point .data at the value like the neighboring entries,
> the per-netns registration rebases it, and the handler reads
> the value directly - no ctl_table copy (Björn Töpel,
> Willem de Bruijn)
> - check the opt-out before parsing: with the knob off, packets
> the parser cannot handle were still dropped (Willem de Bruijn)
> - include virtio_net.h in net/core/dev.c so the static key
> definition sees its declaration (build warning reported by
> Jakub Kicinski)
>
> net: add ip4_parse()
> - add the missing kernel-doc Return: section
> (Jakub Kicinski)
>
>
> Changes since v4:
>
> net: account for ingress-resolved virtio net hdr state
> - count on tun only: dropped the tap, macvtap, ipvtap and
> virtio_net counters (Willem de Bruijn)
> - the driver side branches are in their final form here now,
> moved from "net: resolve uncommon partial checksums at
> ingress" (Willem de Bruijn)
>
> net: resolve uncommon partial checksums at ingress
> - no longer touches the drivers (Willem de Bruijn)
> - a packet too small to be GSO: ignore the tunnel GSO request,
> same as plain GSO ones, and complete wild metadata in place
> (sashiko)
> - document the zero copy interaction (sashiko)
> - honor a preset skb->protocol on ethernet: the stack uses it,
> except on loopback which re-parses the frame (sashiko)
>
> net: add a sysctl to opt out of virtio net hdr checksum validation
> - document the netns lifetime requirement (sashiko)
>
> net: add ip4_parse()
> - pull the whole header, options included, so that the
> transport header offset is within the linear data
> (Willem de Bruijn)
>
>
> Changes since v5:
>
> net: resolve uncommon partial checksums at ingress
> - read both skb->protocol and the frame ethertype: do not
> validate when they disagree, instead of preferring the
> preset protocol; same check after the IP version inference
> where there is no L2 header (Willem de Bruijn)
> - pull the IPv4 options in the helper as introduced, with the
> transport header offset computed before the pull
> (Willem de Bruijn)
> - fold the trivial protocol calculation cleanup, formerly a
> separate patch, in (Willem de Bruijn)
>
> net: add ip4_parse()
> - the options pull moved to the helper introduction in
> "net: resolve uncommon partial checksums at ingress"
>
> Tested: full suite on the final tree, tunnel included.
> um part compiled only.
>
>
> Michael S. Tsirkin (5):
> net: account for ingress-resolved virtio net hdr state
> um: vector: trim skbs before verifying the header
> virtio_net: parse tunnel csum_start little-endian
> net: resolve uncommon partial checksums at ingress
> net: add a sysctl to opt out of virtio net hdr checksum validation
>
> Documentation/admin-guide/sysctl/net.rst | 19 ++
> arch/um/drivers/vector_kern.c | 6 +-
> arch/um/drivers/vector_transports.c | 4 +-
> drivers/net/tap.c | 4 +-
> drivers/net/tun.c | 41 ++-
> drivers/net/virtio_net.c | 2 +-
> include/linux/virtio_net.h | 319 ++++++++++++++++++++++-
> include/net/netns/core.h | 1 +
> net/core/dev.c | 7 +
> net/core/net_namespace.c | 1 +
> net/core/sysctl_net_core.c | 50 ++++
> net/packet/af_packet.c | 4 +-
> 12 files changed, 441 insertions(+), 17 deletions(-)
>
> --
> MST
>
next prev parent reply other threads:[~2026-10-25 13:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 15:09 [PATCH net v6 0/5] more virtio-net csum hardening Michael S. Tsirkin
2026-10-23 15:09 ` [PATCH net v6 1/5] net: account for ingress-resolved virtio net hdr state Michael S. Tsirkin
2026-10-24 15:09 ` sashiko-bot
2026-10-23 15:09 ` [PATCH net v6 2/5] um: vector: trim skbs before verifying the header Michael S. Tsirkin
2026-10-24 15:09 ` sashiko-bot
2026-10-23 15:09 ` [PATCH net v6 3/5] virtio_net: parse tunnel csum_start little-endian Michael S. Tsirkin
2026-10-24 15:09 ` sashiko-bot
2026-10-23 15:09 ` [PATCH net v6 4/5] net: resolve uncommon partial checksums at ingress Michael S. Tsirkin
2026-10-23 19:37 ` Willem de Bruijn
2026-10-23 23:46 ` Michael S. Tsirkin
2026-10-24 15:09 ` sashiko-bot
2026-10-23 15:09 ` [PATCH net v6 5/5] net: add a sysctl to opt out of virtio net hdr checksum validation Michael S. Tsirkin
2026-10-24 15:09 ` sashiko-bot
2026-10-23 18:07 ` [PATCH net v6 0/5] more virtio-net csum hardening Chris Arges
2026-10-24 15:42 ` Michael S. Tsirkin
2026-10-24 16:08 ` Willem de Bruijn
2026-10-24 16:20 ` Michael S. Tsirkin
2026-10-25 13:50 ` Michael S. Tsirkin [this message]
2026-10-28 22:43 ` Jakub Kicinski
2026-10-29 7:22 ` Michael S. Tsirkin
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=20261025094449-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=bjorn@kernel.org \
--cc=carges@cloudflare.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=jasowangio@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxk@qualcomm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phil@nwl.cc \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux.dev \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xuanzhuo@linux.alibaba.com \
/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.