Michael wrote in v7 that he would be on other things for a while and
posted it in case anyone wants to take it up, so here it is, rebased and
with the review comments addressed. Michael, if you already have a newer
version, I am happy to drop this one in favor of it. Patches 1-4 and 6
are yours; what I changed is noted above my sign-off.
Changes since v7:
- Rebased. Commit 73e08d50eb13 ("net: virtio: validate outer protocol of
UDP tunnel GSO packets") has the header parsing helpers and the outer
header checks, so those are gone from patch 4.
- Patch 4: has_eth is passed to virtio_net_hdr_to_skb() as well, instead
of looking at the device type. I dropped Chris' Tested-by, as this is
no longer what he tested.
- Patch 4: the tnl_csum_negotiated check is ahead of the validation
again, as Willem pointed out.
- Patch 5 is new: the outer checksum of tunnel packets that are too small
to segment. Willem asked for it as a separate patch.
- Patch 6: the sysctl does not turn off the outer header checks, which
are in the tree unconditionally now. I turned the Reviewed-by tags into
Cc, as that changes what was reviewed.
The two issues Michael listed as open in v7 are still open, hence the
RFC: the inner packet of a tunnel can have a valid header at
inner_nh_offset that overlaps the real transport header, and completing
the checksum at input breaks nf/BPF programs that edit the payload and
rely on CHECKSUM_PARTIAL.
I compared no patches, 1-4 and 1-6 on arm64 (qemu, TCG) with frames
written to a tap:
- Non-GSO UDP tunnel packets that ask for the outer checksum, over IPv4
and IPv6, go out with a wrong one without the series and with 1-4, and
with a correct one with 1-6.
- When the inner packet is a fragment, 1-4 reject them with EINVAL, and
1-6 send them with a correct checksum.
- GSO behind an IPv6 AH is accepted without the series, and rejected
with 1-4 and with 1-6.
- A plain UDP packet with csum_offset at the destination port is
completed at input and counted in rx_csum_sw. One with good metadata is
not counted.
The objects touched build on x86_64 with W=1 after each patch. At the end
of the series I also built the um objects, and linked an arm64 kernel
with CONFIG_INET=n and VIRTIO_NET=y.
Based on net e6474ead54b8, where the tests were run as well.
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
Showta Ishizaki (1):
net: virtio: compute the outer checksum of non-GSO tunnel packets
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 | 44 +++-
drivers/net/tun_vnet.h | 4 +-
drivers/net/virtio_net.c | 2 +-
include/linux/virtio_net.h | 247 ++++++++++++++++++++++-
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 | 16 +-
13 files changed, 381 insertions(+), 24 deletions(-)
base-commit: e6474ead54b8acecb8b0462dde2d77f46d2b7dc1
--
2.54.0