From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796443313; b=EMjNHacS2DFp1VtvHEe4HGd3JfjzxMjOI4vWxxAkZhUYOMcc97EQ5v6fswWf/Npcz+o5 7spLj/bM/l+csRgpIvxBEqDIRTbiORte+vuIRAjTu3+trVTDZjNUcPLcgKUOQ8Va+4NIK 7UqofJSpII+t6IbDnkUu8JktpEH3sTP0gI9doRC0NnNetVNFepLmoRop9lfhsoo0PS0uq +SqStVCIlWNH/CF+iGobMzoWgPtSv5hhtUgtlbE5q9KlmECcqtsyegimM5A0gH1uG0ZRr ezKQiz0lcnGfqEVC2a+yKabDEd6Inqm2Bl8CfictBZwTtRaWyVcyZCUVTu+TEHZj4eA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796443313; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=hk824vLR3s8A6OFeEB3kMUK6NQSCpAlKNCVpv39IJPw=; b=csLU82KzSzc33zBYeMwmOBCf3lc37e3m/6gQjT1x1d2pYBnaSY+B/hXTcsmp7IyvSVPd BytEjZHH3tAl9597oPa6jFF30Km7hpxCU9U98iqqVP7YTYu3O8YHlgtMCj0XWHEU8UrO6 U1mFymc+keOMGShkF0djB22CFYiPyDawMbfJmJo3vEIejWg/z8i8rHUhUckhSXIxBl5re 3jHgNSrA3I1tv07YEAz6gqtt7UR7QqW/nf5BgBV82SWka5+vOrjCP8CxFWFU3PxNOFzcG MkR2GwLuj/2QOaGluOCxApNhqbcCVJBroFGoXOaRUxBr/CoG/anrv38Cyh4lmxU4GGA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=C84RZGux; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE577606A32D for ; Sat, 5 Dec 2026 04:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=C84RZGux Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88DB61F00A10; Sat, 5 Dec 2026 04:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796443313; bh=hk824vLR3s8A6OFeEB3kMUK6NQSCpAlKNCVpv39IJPw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=C84RZGuxGdgLxdDVcSdFRToWTOZr5TGGT7il8ujMZWsZfpg7vVrXXqMxwXmc7yrzA tZFXX6sOAu1plQyZqDitaLxcXEyOQOv/wTJ/ChVYy40NDy59CkEHxrCE1+xiZSneKy JrrVPYXBjOOH+ZOna+DczC30l4LCt6QsoAdohqGlZRl225sNx0mYZpJnOS9abwhqZ9 5o/48DV92whNynw/J/qRu91W2bW52hauEauEEaoDU4oqa8+DIq2CC9HbojtoDImNpL aqC1wv7BWf/ISF28tCucpDguer46bdoRoCAXi1TeZzyRHyNVXkQbEplfknW11VVJCm Qn9c+i37ha6ow== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RFC net v11 5/6] net: virtio: compute the outer checksum of non-GSO tunnel packets Reply-To: sashiko-reviews@lists.linux.dev To: "Showta Ishizaki" Cc: virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261204.rfcv11.99731.5.zakinko@snowrabbit.org> References: <20261204.rfcv11.99731.0.zakinko@snowrabbit.org> <20261204.rfcv11.99731.5.zakinko@snowrabbit.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 04:01:53 +0000 X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 =3D=3D IPPROTO_UDP && outer_th =3D=3D 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 =3D skb_ensure_writable(skb, outer_th + sizeof(*uh)); > + if (err) > + return err; > + > + uh =3D (struct udphdr *)(skb->data + outer_th); > + len =3D ntohs(uh->len); > + uh->check =3D 0; > + if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { > + csum =3D 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 =3D 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 =3D=3D 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 =3D (void *)(skb->data + nhoff); > + > + uh->check =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204.rfcv11.997= 31.0.zakinko@snowrabbit.org?part=3D5