Article View: linux.kernel.netdev
Article #17290Re: [PATCH net-next 1/3] tun: don't probe the transport header of packets written by userspace
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 15:25
Date: Mon, 16 Nov 2026 15:25
160 lines
14421 bytes
14421 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] After the patch, a TAP packet that is neither GSO nor
VIRTIO_NET_HDR_F_NEEDS_CSUM leaves tun_get_user() with…
- [Medium] On the default tun/tap receive path (no IFF_NAPI, so no GRO;
delivery through tun_rx_batched()/netif_rx()), skb->transport_header…
- [Low] The patch removes skb_probe_transport_header() only from
tun_get_user().
--
tun: don't probe the transport header of packets written by userspace
This commit removes the skb_probe_transport_header() call from
tun_get_user(). For NEEDS_CSUM and GSO packets it relies on
skb_partial_csum_set() and __virtio_net_hdr_to_skb() to set the transport
header, and for all other packets on the IPv4/IPv6 receive paths.
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 8920c797acfd7..9fc60a73fb963 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1960,7 +1960,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> net_zcopy_complete(NULL, msg_control, false);
>
> skb_reset_network_header(skb);
> - skb_probe_transport_header(skb);
> skb_record_rx_queue(skb, tfile->queue_index);
>
> if (skb_xdp) {
[Severity: Medium]
Without the probe, a TAP frame that is neither GSO nor
VIRTIO_NET_HDR_F_NEEDS_CSUM reaches tun's own do_xdp_generic() call with
transport_header still at the unset value (~0). This happens before
__netif_receive_skb_core() gets a chance to reset it.
Can the generic XDP copy path turn that sentinel into an offset that looks
valid but is wrong?
skb_xdp starts at 1 in tun_get_user(). It stays 1 for blocking, zerocopy,
large and IFF_NAPI_FRAGS writes, because tun_can_build_skb() rejects those.
These skbs come from tun_alloc_skb() with only tun->align of headroom, or
they are nonlinear, so they always take this branch:
net/core/dev.c:netif_receive_generic_xdp() {
...
if (skb_cloned(skb) || skb_is_nonlinear(skb) ||
skb_headroom(skb) < XDP_PACKET_HEADROOM) {
if (netif_skb_check_for_xdp(pskb, xdp_prog))
...
}
That branch reallocates through skb_pp_cow_data() or pskb_expand_head().
Both of them end up here:
net/core/skbuff.c:skb_headers_offset_update() {
...
skb->transport_header += off;
skb->network_header += off;
if (skb_mac_header_was_set(skb))
skb->mac_header += off;
...
}
Only mac_header gets a was_set check. 0xffff + off wraps in the u16 to
off - 1, which points into the new uninitialized headroom just before
skb->data. Because of that, skb_transport_header_was_set() returns true,
and the fallback in __netif_receive_skb_core() is skipped:
if (!skb_transport_header_was_set(skb))
skb_reset_transport_header(skb);
Anything that runs before L3 would then see this offset: tc ingress,
bridge or OVS forwarding into another device's xmit path, and
XDP_TX/XDP_REDIRECT through generic_xdp_tx(). ip_rcv_core() and ipv6_rcv()
overwrite it, so locally delivered IP traffic is not affected.
Before this patch, skb_probe_transport_header() had already set a valid L4
offset for dissectable IPv4/IPv6 frames, so the reallocation shifted a
valid value.
The missing sentinel check in skb_headers_offset_update() is older than
this patch. However, this patch exposes all well-formed tun frames to it,
not only the ones the dissector rejected. The commit message says these
packets are handled "as for packets from NICs". For NICs in non-DEBUG_NET
builds, __netif_receive_skb_core() resets the transport header before
generic XDP runs, and this tun-local XDP path skips that reset.
[Severity: Medium]
On the default receive path (no IFF_NAPI, delivery through
tun_rx_batched() or netif_rx()), will tc ematches that use layer transport
on a tun/tap ingress still match?
For non-GSO, non-NEEDS_CSUM packets, nothing sets the L4 offset before
__netif_receive_skb_core() anymore. In non-DEBUG_NET builds that function
resets transport_header to the network header before tc ingress runs. With
CONFIG_DEBUG_NET the reset is compiled out and the header stays unset.
em_cmp, em_nbyte and em_text get their base pointer from here:
include/net/pkt_cls.h:tcf_get_base_ptr() {
...
case TCF_LAYER_TRANSPORT:
if (!skb_transport_header_was_set(skb))
break;
return skb_transport_header(skb);
...
}
Take an existing filter like "cmp(u16 at 2 layer transport eq 80)". It
used to match the destination port. Now it would compare bytes of the IP
header, or never match at all on DEBUG_NET builds.
ip_rcv_core() and ipv6_rcv() only set the transport header after tc
ingress and bridge handling, so the commit message's "the IPv4/IPv6
receive paths set it" doesn't cover these users.
tun_xdp_one() still probes, so the same filter now classifies a packet
differently depending on whether it came in through write()/sendmsg or
vhost-net batched TX.
[Severity: Low]
Should tun_xdp_one() get the same change? It still has the probe:
drivers/net/tun.c:tun_xdp_one() {
...
skb->protocol = eth_type_trans(skb, tun->dev);
skb_reset_network_header(skb);
skb_probe_transport_header(skb);
skb_record_rx_queue(skb, tfile->queue_index);
...
}
That path also carries packets written by userspace: vhost-net batched
guest TX goes through tun_sendmsg() with TUN_MSG_PTR. It builds the skb the
same way and delivers it through netif_receive_skb() or the NAPI queue.
The argument for dropping the probe applies to it unchanged.
The subject says the probe is dropped for "packets written by userspace",
but the vhost-net batched path keeps it. The two receive paths of one tun
device now also set up the transport header differently. If this is
intentional, could the commit message mention it and give the reason?
The tap.c call sites in tap_get_user() and tap_get_user_xdp() are a
different case. Those packets go to dev_queue_xmit() on the lower device,
so the receive-path reasoning doesn't apply to them.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112150612.3866546-1-antonio%40mandelbit.com
Technical Details
Message-ID:
<179484274982.3136.10527408814471189308@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364500-linux-kernel-netdev=dewy.ruReferences:
<20261112150612.3866546-2-antonio@mandelbit.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364500-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 1/3] tun: don't probe the transport header of packets written by userspace Date: Mon, 16 Nov 2026 15:25:49 +0000 Organization: Usenet Network Message-ID: <179484274982.3136.10527408814471189308@kernel.org> References: <20261112150612.3866546-2-antonio@mandelbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2098567"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:gP9ovKVfBC4QAXHWbYQN/1wS+Y8= sha256:3yhQutvA3EsCVKAL2bCAk7pyfqIzJSuLq5YxTGgRdfM= sha1:WLBMSY65QnG/RWB5SIlwu/dbP2E= sha256:igzHmoaZQAoYr6KxjXWHr6c4YaRBJFr/AT0bOb4k6qA= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id CD6F9114CAB; Mon, 16 Nov 2026 18:27:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DHq4jIQOBHby; Mon, 16 Nov 2026 18:26:58 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364500-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 18A58114CA8; Mon, 16 Nov 2026 18:26:47 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 134A53115C; Mon, 16 Nov 2026 15:25:57 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794842752; b=TQf4Ky9BqlgqBYNy/wS3pFRTcmj8jOVGVO9wmCOtNAAox1WEus8NE0oMlWwiRJuNsdLF WhC/bCYNZutYjtuUwvRZcJgK4skQ5n6PvAlG6Nwt/xCIH9oKtiQvPoZ23yXh9rB21Zw4g pJnx7FelLYbQiaWSNIoQoj5dzcdW1Si6M1wshsk3Yw9CY0DhzYSJt6yDurHDfzElncKcz yp2o4bPKHg1799HjtS9knRmgDRCJle+0HYHGSse0O+GMBnIOqHQnYkfXPY4yNw8B2I2jz D87WjDmkz0vnJ/heela+sFCOGeZNbyoQJ4cmVyRL4Y0Z25OKWLw7Q/yGM26dhLUxyoQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794842752; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=coYmGyqn3W2sbPWx2GMfbYwCGxsifNHyu6iC/K2Vhz4=; b=rBWqwujn5qvCIHRN3OKHMbE7KG/0sQskduCKJNUeEAbvzyU9WtMilUmpine9cMo8EpKr k+TlFaKJEGuoSGCfWAxqHo05rl6JrGySHJzBIHWbdXryfDG98eV+LTIFoxbz3tsOPjcjn 196j5V9poO09TN5jzNF7qSzw0fxEC/XHF+/u6aXSTWDiVhJGUZGZyoVQ+zs1zNDpFR706 WAayZ3+CKd+LZDmcho2ynNBmkyX1Cr/ilyvvsPOOl/xDfI8EzcaiXGbmv/U/C57vTeh1J qZXMlofpPh5wsrR295eVZopwHH+7Fl5g06kYe+FKYoqlnaGKwxq19gBFDRLxE58WNYA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=m69MbBCr; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 420FF606A896; Mon, 16 Nov 2026 15:25:52 +0000 (UTC) X-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=m69MbBCr X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794842751; b=Q425RvtRL7AgofMtkyT+3UoeoBjBhj8YH6LMkWayZJspWw+OMipMQwalleRBt16rUpjO qlzez10J6mKmEmISGu53ti5PUQaDuTr5R7MNALv1+HdN3X6qc9RZKkcQXTIW5hwXvJruH xrRHYzzJAAD0pVkctWqHBihBkwWgv+vlHzHizxamC3sbcvQvdhwhvNLlexBIUfV0dcPw3 tYk84nPRw91I/VweFlknOni6Jy3ErHTWdM5G9VfjKIicgr/8iH9WQ2SFTIuNQxHt8eO0W +VzwbwRly2lVzy1FAWpn24qEKy20oM6arpbW0iygCe7qiVKRIJ7htI6R10wdfV7Zl0A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794842751; 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=coYmGyqn3W2sbPWx2GMfbYwCGxsifNHyu6iC/K2Vhz4=; b=f25zGdtCleFdT0jlsr5h4XnAWHSqrma1O3ZiAVUsLDsw11rXn7SGjgRZVliRizsStNTU z4kKif1qJuNf7RttlcfGTc9a7ELj/Uu6ZhwppqjTyz7qwddh+fFLPSaWtTRlXDMbHYjqP eR25Rq72C+FthGjyR0Km8CZQjm37CZCTmKH6Nw8yPLJ4qcbsKAKGTrGQGlzOu/2MQddc7 AO50S/4OjXj90DXjcake/0fVnsS1F4QT5gxmiy8qBFf0e9C38KJ4L6oLnHSCNUQE7+KSo pWLHlTYYkWU7pmwpyXBTEOq5eunT3yvPi5pyYBUHVWs/BP+pgDInAAq/Levju0u5Jpg== X-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=m69MbBCr; arc=none smtp.remote-ip=100.103.45.18 X-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 53ED0606A882; Mon, 16 Nov 2026 15:25:51 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BB431F000C4; Mon, 16 Nov 2026 15:25:50 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794842751; bh=coYmGyqn3W2sbPWx2GMfbYwCGxsifNHyu6iC/K2Vhz4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=m69MbBCrYZ+1taSVT1fcOttETC+mWp9jOTimABeTKTtlavvNTArPbiOvXUbrhG3Kv nFwKxLtKxWuOcGOBr8d0+mcOw8/Et0viNO7sc0X9M1iHEEOCjTu0LsMBFQVGrdK0lJ Mb8mkSLT1OBzu+gbKPqvOeyHhJ1NboK/SCEdS4wY4q2nyiTo1BQ0W4QPX0g2Uwkd+h OscGMSFqUBnig7ykZpctWM9wfbU5JofUE8N9RoNVlyFCJrYsKaUAJtw/xOty4+7jeq bGkPIuF89PZqXsHRGGDHcWGqWcbXsXVgH9ANDsR5aZ4Msy2tz5h+Ifi8cgabLvTy1k hrjDgmsCihdJQ== X-Cc: willemdebruijn.kernel@gmail.com, jasowangio@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, netdev@vger.kernel.org, bpf@vger.kernel.org X-In-Reply-To: <20261112150612.3866546-2-antonio@mandelbit.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list