From: Wang Liang <wangliang74@huawei.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
<mst@redhat.com>, <jasowang@redhat.com>,
<xuanzhuo@linux.alibaba.com>, <eperezma@redhat.com>,
<pabeni@redhat.com>, <davem@davemloft.net>, <willemb@google.com>,
<atenart@kernel.org>
Cc: <yuehaibing@huawei.com>, <zhangchangzhong@huawei.com>,
<netdev@vger.kernel.org>, <virtualization@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, <steffen.klassert@secunet.com>,
<tobias@strongswan.org>
Subject: Re: [PATCH net] net: check the minimum value of gso size in virtio_net_hdr_to_skb()
Date: Mon, 28 Jul 2025 11:36:34 +0800 [thread overview]
Message-ID: <08399323-6bab-44f6-bc21-21faf68cd73d@huawei.com> (raw)
In-Reply-To: <68865ecee5cc4_b1f6a29442@willemb.c.googlers.com.notmuch>
在 2025/7/28 1:15, Willem de Bruijn 写道:
> Willem de Bruijn wrote:
>> But so the real bug, an skb with 4B in the UDP layer happens before
>> that.
>>
>> An skb_dump in udp_queue_rcv_skb of the GSO skb shows
>>
>> [ 174.151409] skb len=190 headroom=64 headlen=190 tailroom=66
>> [ 174.151409] mac=(64,14) mac_len=14 net=(78,20) trans=98
>> [ 174.151409] shinfo(txflags=0 nr_frags=0 gso(size=4 type=65538 segs=0))
>> [ 174.151409] csum(0x8c start=140 offset=0 ip_summed=3 complete_sw=0 valid=1 level=0)
>> [ 174.151409] hash(0x0 sw=0 l4=0) proto=0x0800 pkttype=2 iif=8
>> [ 174.151409] priority=0x0 mark=0x0 alloc_cpu=1 vlan_all=0x0
>> [ 174.151409] encapsulation=0 inner(proto=0x0000, mac=0, net=0, trans=0)
>> [ 174.152101] dev name=tun0 feat=0x00002000000048c1
>>
>> And of segs[0] after segmentation
>>
>> [ 103.081442] skb len=38 headroom=64 headlen=38 tailroom=218
>> [ 103.081442] mac=(64,14) mac_len=14 net=(78,20) trans=98
>> [ 103.081442] shinfo(txflags=0 nr_frags=0 gso(size=0 type=0 segs=0))
>> [ 103.081442] csum(0x8c start=140 offset=0 ip_summed=1 complete_sw=0 valid=1 level=0)
>> [ 103.081442] hash(0x0 sw=0 l4=0) proto=0x0800 pkttype=2 iif=8
>> [ 103.081442] priority=0x0 mark=0x0 alloc_cpu=0 vlan_all=0x0
>> [ 103.081442] encapsulation=0 inner(proto=0x0000, mac=0, net=0, trans=0)
>>
>> So here translen is already 38 - (98-64) == 38 - 34 == 4.
>>
>> So the bug happens in segmentation.
>>
>> [ongoing ..]
> Oh of course, this is udp fragmentation offload (UFO):
> VIRTIO_NET_HDR_GSO_UDP.
>
> So only the first packet has an UDP header, and that explains why the
> other packets are only 4B.
>
> They are not UDP packets, but they have already entered the UDP stack
> due to this being GSO applied in udp_queue_rcv_skb.
>
> That was never intended to be used for UFO. Only for GRO, which does
> not build such packets.
>
> Maybe we should just drop UFO (SKB_GSO_UDP) packets in this code path?
Thank you for your analysis, it is totally right!
After segment in udp_queue_rcv_skb(), these segs are not UDP packets, which
leads the crash.
The packet with VIRTIO_NET_HDR_GSO_UDP type from tun device perhaps should
not enter udp_rcv_segment().
How about not do segment and pass the packet to udp_queue_rcv_one_skb()
directly, like this:
diff --git a/include/linux/udp.h b/include/linux/udp.h
index 4e1a672af4c5..0c27e5194657 100644
--- a/include/linux/udp.h
+++ b/include/linux/udp.h
@@ -186,6 +186,9 @@ static inline bool udp_unexpected_gso(struct sock
*sk, struct sk_buff *skb)
if (!skb_is_gso(skb))
return false;
+ if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
+ return false;
+
if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 &&
!udp_test_bit(ACCEPT_L4, sk))
return true;
next prev parent reply other threads:[~2025-07-28 3:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 8:30 [PATCH net] net: check the minimum value of gso size in virtio_net_hdr_to_skb() Wang Liang
2025-07-24 13:29 ` Willem de Bruijn
2025-07-25 7:55 ` Wang Liang
2025-07-27 16:36 ` Willem de Bruijn
2025-07-27 17:15 ` Willem de Bruijn
2025-07-28 3:21 ` Jason Wang
2025-07-28 3:50 ` Willem de Bruijn
2025-07-29 2:40 ` Jason Wang
2025-07-28 3:36 ` Wang Liang [this message]
2025-07-28 13:45 ` Willem de Bruijn
2025-07-25 8:55 ` Xuan Zhuo
2025-07-29 12:22 ` Wang Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08399323-6bab-44f6-bc21-21faf68cd73d@huawei.com \
--to=wangliang74@huawei.com \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.com \
--cc=tobias@strongswan.org \
--cc=virtualization@lists.linux.dev \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yuehaibing@huawei.com \
--cc=zhangchangzhong@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox