freenode
Kernel & Low-Level

Kernel hardens virtio-net against rogue checksum offload metadata

Untrusted csum_start and offset values can no longer leave CHECKSUM_PARTIAL pointing at arbitrary packet bytes after protocol decisions have been made.

Linux networking maintainers are tightening how the kernel handles virtio net headers that request partial checksum offload, after researchers showed that untrusted hardware or guests could place CHECKSUM_PARTIAL at almost any offset in a packet.

The problem, first reported by Paulos Yibelo and later explored further by Chris Arges and others, is that a later checksum completion can rewrite bytes the stack has already inspected. Depending on path and timing, protocol processing can therefore see one view of the packet before the edit and another after it. Earlier fixes caught some high-impact cases; the broader approach is to stop trusting arbitrary offload metadata on ingress.

Michael S. Tsirkin’s latest series for the net tree validates csum_start and csum_offset against a real TCP or UDP header (including VLAN, IPv4 options, and IPv6 extension headers). Only matching metadata keeps CHECKSUM_PARTIAL. Other non-GSO packets have their checksum completed in software before any protocol work runs. Unrecognized GSO metadata is dropped rather than segmented with wild offsets. The same rules apply to the inner header of UDP tunnels. Packets that never request needs-csum are unchanged.

That is stricter than the old path: some odd non-GSO traffic pays a software checksum cost, and unparsable GSO frames are discarded. A per-network-namespace sysctl, net.core.virtio_net_hdr_validate, defaults to on and can restore the prior trust model for setups that do no protocol processing on these packets. Related fixes cover User Mode Linux receive trimming before header checks and consistent little-endian parsing of tunnel csum_start fields so misconfigured endianness cannot push the inner transport header past the end of the skb.

Tsirkin notes the class of bugs drew wide attention after Yibelo’s report and argues for closing it promptly even though the series is large for stable backports. Willem de Bruijn reviewed the approach. The work targets the main networking tree rather than a minimal stable cherry-pick.