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=1796301541; b=SdhLUcK2DEAN6VRSvVAflYY3Uwtj/W/0FSlZZPcXPNjYdfwC0a1kd1qmruiMpPEvDnvd BThWTUJhAloJq2/gvGPuO86PrWKJgMf1vBQJkikw7T6mAhkjXNHtvSdihZN31KeacwG6J uETgFY80lPlMY6TG4T5R0q00o0OndZnrff3YVOct5nwM/EwxGiSKvBKtkK3gwU2AT2rfy 7v3Sxjc78o6bbsX+uBFq5s3F48twboBBsOSaoz0cV72IqZSMH6GR+k/YXTUGoOAgBuUtv YwIu22l83DwP1QWY4lw85CQvovw8HTuEwXzz9aUCcul4UXEhXzQfCcOWWfOJLmlrNVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796301541; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=xTSSt6Nrw7Pom8Ttc1VGW/qD+IeQzSk6349JVAU/8Mg=; b=QuiJODcOcwgal4cVnj65uFmBArTl9bzsFJ5kRcUig//8U91dPQPaCQc6b5i6ob/nNDab ax8o7Xrk4c7fB/Ujag1Yflk4jmV9t7+Aqcjn7tvhyuiufUgQsU9iGWmIsDy0IA7isv0dG WPWunvxAqyKh/3884zf97i3m3e/XCUhNihhcngt53BzoJlnVYddZHHzQSiGuCQEgl9+JN UxstUEdEQGw/ewEdCsbDAoiI+nu2g+hcvHeyYiknw57GIPvxYcwe/nc1Vvvj5P6NuYSA2 MyAluf/eDlfdIKBbvdiVDwehua/7j46pC7r1faRNHDo7+l2CEq/UrQaATThZXJZ58dA== 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=jLtuqpJf; 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 7567B606A68A; Thu, 3 Dec 2026 12:39:01 +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=jLtuqpJf Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFE481F000C1; Thu, 3 Dec 2026 12:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796301541; bh=xTSSt6Nrw7Pom8Ttc1VGW/qD+IeQzSk6349JVAU/8Mg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=jLtuqpJfqfeyPKdBMQH6b888d1nnvV2v7JbpgeZwIndWVIDHCik5KAqA23y4y3MfB 8roRK5n8p7wahB/5TwpH75ruQS4DmK00WvMiUPZ9+0ApFk/EKESecunMOUSCMWlzV2 wYiJt49D0BakTWtgAmfGFPDEu7eELouYA3Erb6uw6fWDxx+u32RYyDB4QSRMHE7OWz 4E2+DljWFA6sKzCsyRIBQzSHi1rnO6v/du1R93M4LAKo6uU0G9QF/jSS7arBh2eS78 F4j/HJhRD692qSbbuqcu5qNpoWflbKBV/9Xsszn8AVM39D7dHHxHTrRI21NnNRAgWX m9D/CpV8Rwx2A== Subject: Re: [PATCH net-next v8 2/5] erspan: take the COS from the mirrored frame, not from the tunnel family From: netdev-bot+sashiko@kernel.org To: littlesmilingcloud@gmail.com Cc: netdev@vger.kernel.org, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, horms@kernel.org, dsahern@kernel.org, willemb@google.com, idosch@nvidia.com, fw@strlen.de, u9012063@gmail.com, mvohra@vmware.com, matthias.may@westermo.com, mazin@getstate.dev, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 03 Dec 2026 12:38:59 +0000 Message-ID: <179630153945.3146.8297999303296790417@kernel.org> In-Reply-To: <20261202123613.1708463-3-littlesmilingcloud@gmail.com> References: <20261202123613.1708463-3-littlesmilingcloud@gmail.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The commit fixes two bugs that are visible on the wire, but it has no Fixes: tag. Pre-existing issues: - [Medium] erspan_frame_tos() (include/net/erspan.h) still gets the COS wrong for double-tagged (QinQ) frames mirrored from tc ingress. -- erspan: take the COS from the mirrored frame, not from the tunnel family This patch changes how erspan_build_header() and erspan_build_header_v2() get the COS. They used to pick IPv4 or IPv6 from the tunnel family; now they pick it from the mirrored frame, using skb->protocol and, for VLAN types, the version nibble at the network header. The read uses skb_header_pointer() and gives 0 if the bytes are not there, and the is_ipv4 argument is dropped from both builders. > - a 14 byte non-IP frame gives a KMSAN report when the packet is > received on the other side; with the patch it does not. > > Signed-off-by: Anton Danilov [Severity: Low] Should this commit carry Fixes: tags? It fixes two bugs that show up on the wire. One is the COS taken from the tunnel family. The other is the read past the end of a short non-IP frame, which puts uninitialized bits into the transmitted COS field. The previous patch in the series, "erspan: bound the VLAN tag read in erspan_build_header{,_v2}()", has Fixes: tags and a syzbot Closes:. Its message says the KMSAN reports only go away "with this patch and the next one, which bounds the remaining read of this kind". Without tags here, stable tooling could take the previous patch alone and leave the uninitialized COS read in stable kernels. Based on blame of the removed reads, the candidates look like: Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN") Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre") Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support") a3222dc95ca7 only moved this code into erspan.h, so it does not look like the origin. > diff --git a/include/net/erspan.h b/include/net/erspan.h > index 6bda757b6da21..c272b3fb9bfd6 100644 > --- a/include/net/erspan.h > +++ b/include/net/erspan.h [ ... ] > @@ -170,9 +172,46 @@ static inline u8 tos_to_cos(u8 tos) > return cos; > } > > +/* TOS of the mirrored frame, for the COS field, read at the network > + * header. The IP version comes from skb->protocol or, for a VLAN type, > + * from the version field there, and not from the tunnel family. The > + * bytes are read with skb_header_pointer(), so a frame that does not > + * have them gets 0. > + */ > +static inline u8 erspan_frame_tos(const struct sk_buff *skb) > +{ [ ... ] > + /* Version and DS field fit in the first 16 bits of either IP header. */ > + iph = skb_header_pointer(skb, offset, sizeof(_prefix), &_prefix); > + if (!iph) > + return 0; > + > + if (eth_type_vlan(type)) { > + if (iph->version == 4) > + type = htons(ETH_P_IP); > + else if (iph->version == 6) > + type = htons(ETH_P_IPV6); > + } > + > + if (type == htons(ETH_P_IP)) > + return iph->tos; > + if (type == htons(ETH_P_IPV6)) > + return ipv6_get_dsfield((const struct ipv6hdr *)iph); > + return 0; > +} [Severity: Medium] This is a pre-existing issue and was not introduced by this patch. For double-tagged (QinQ) frames mirrored from tc ingress, does this heuristic still take the COS from VLAN ID bits? On receive, __netif_receive_skb_core() untags only once before sch_handle_ingress(): if (eth_type_vlan(skb->protocol)) { skb = skb_vlan_untag(skb); skb_vlan_untag() moves the outer tag into hwaccel and sets skb->protocol to the inner 0x8100. It then calls skb_reset_network_header(), which leaves the network header on the inner TCI. If the NIC already stripped the outer tag, the network header ends up there as well. The path then continues: tcf_mirred_to_dev() -> validate_xmit_vlan() -> erspan_xmit() -> erspan_build_header() -> erspan_frame_tos() erspan has no NETIF_F_HW_VLAN_*_TX, so validate_xmit_vlan() pushes the tag back inline with __vlan_insert_inner_tag(). That moves only mac_header and sets skb->protocol to the outer vlan_proto. In erspan_frame_tos(), eth_type_vlan(type) is then true, and iph->version is the top nibble of the inner TCI (PCP << 1 | DEI): - inner PCP 2 with DEI 0 is taken as IPv4, and iph->tos returns VID bits 0-7 - inner PCP 3 with DEI 0 is taken as IPv6, and ipv6_get_dsfield() returns TCI bits 4-11 - any other PCP gives COS 0, even when the payload is IP The commit message says: The TOS is still read at the network header. That is where the stack, tc mirred and packet sockets leave the IP header, ... Is that accurate for this ingress QinQ path? Could it be added to the list of cases where the COS stays wrong? Also, the later patch "ip6_gre: classify the inner packet once on transmit" adds ip6gre_xmit_classify(). It walks the tags with __vlan_get_protocol() and calls skb_set_network_header() on the inner IP header. No later patch in the series seems to change erspan_xmit() or erspan_fb_xmit() in net/ipv4/ip_gre.c. At the end of the series, would the same QinQ frame get a different COS over erspan than over ip6erspan? -- Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202123613.1708463-1-littlesmilingcloud%40gmail.com