gso: fix dodgy bit handling for GSO_UDP_L4
Subsystems (3)
PATCH v2 1/1 gso: fix dodgy bit handling for GSO_UDP_L4
Commit 1fd54773c267 ("udp: allow header check for dodgy GSO_UDP_L4 packets.") checks DODGY bit for UDP, but for packets that can be fed directly to the device after gso_segs reset, it actually falls through to fragmentation:
https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2WaDo28KzYDg+A@mail.gmail.com/
This change restores the expected behavior of GSO_UDP_L4 packets.
---
v2: dropped modifications to tcp/sctp on DODGY bit removal after validating gso_segs. Also moved the UDP header check into __udp_gso_segment (per Willem's suggestion).
--- net/ipv4/udp_offload.c | 16 +++++++++++----- net/ipv6/udp_offload.c | 3 +-- 2 files changed, 12 insertions(+), 7 deletions(-)
net/ipv4/udp_offload.c +11 -5
@@ -274,13 +274,20 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,__sum16 check;__be16 newlen; -if (skb_shinfo (gso_skb)->gso_type &SKB_GSO_FRAGLIST ) -return __udp_gso_segment_list (gso_skb, features, is_ipv6); - mss =skb_shinfo (gso_skb)->gso_size;if (gso_skb->len <=sizeof (*uh) + mss)return ERR_PTR (-EINVAL ); +if (skb_gso_ok (gso_skb, features |NETIF_F_GSO_ROBUST )) { +/* Packet is from an untrusted source, reset gso_segs. */ +skb_shinfo (gso_skb)->gso_segs =DIV_ROUND_UP (gso_skb->len -sizeof (*uh), + mss); +return NULL ; + } + +if (skb_shinfo (gso_skb)->gso_type &SKB_GSO_FRAGLIST ) +return __udp_gso_segment_list (gso_skb, features, is_ipv6); +skb_pull (gso_skb,sizeof (*uh));/* clear destructor to avoid skb_segment assigning it to tail */
@@ -388,8 +395,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,if (!pskb_may_pull (skb,sizeof (struct udphdr ))) goto out; -if (skb_shinfo (skb)->gso_type &SKB_GSO_UDP_L4 && - !skb_gso_ok (skb, features |NETIF_F_GSO_ROBUST )) +if (skb_shinfo (skb)->gso_type &SKB_GSO_UDP_L4 )return __udp_gso_segment (skb, features, false); mss =skb_shinfo (skb)->gso_size;
net/ipv6/udp_offload.c +1 -2
@@ -43,8 +43,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,if (!pskb_may_pull (skb,sizeof (struct udphdr ))) goto out; -if (skb_shinfo (skb)->gso_type &SKB_GSO_UDP_L4 && - !skb_gso_ok (skb, features |NETIF_F_GSO_ROBUST )) +if (skb_shinfo (skb)->gso_type &SKB_GSO_UDP_L4 )return __udp_gso_segment (skb, features, true); mss =skb_shinfo (skb)->gso_size;
Signature · 1 line
2.30.2
Quoted 6 lines · Yan Zhai
Commit
1fd54773c267("udp: allow header check for dodgyGSO_UDP_L4packets.") checks DODGY bit for UDP, but for packets that can be fed directly to the device aftergso_segsreset, it actually falls through to fragmentation:
Quoted 7 lines
https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2WaDo28KzYDg+A@mail.gmail.com/
This change restores the expected behavior of
GSO_UDP_L4packets.Fixes 1fd54773c267 ("udp: allow header check for dodgy GSO_UDP_L4 packets.")Suggested-by Willem de Bruijn <[email protected]>Signed-off-by Yan Zhai <[email protected]>
for next time: places hyperlinks in the block of tags at the bottom of the commit as "Link: ${URL}"
Quoted 10 lines · Yan Zhai
Commit
1fd54773c267("udp: allow header check for dodgyGSO_UDP_L4packets.") checks DODGY bit for UDP, but for packets that can be fed directly to the device aftergso_segsreset, it actually falls through to fragmentation:https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2WaDo28KzYDg+A@mail.gmail.com/
This change restores the expected behavior of
GSO_UDP_L4packets.
Quoted 9 lines
Fixes 1fd54773c267 ("udp: allow header check for dodgy GSO_UDP_L4 packets.")Suggested-by Willem de Bruijn <[email protected]>Signed-off-by Yan Zhai <[email protected]>---
v2: dropped modifications to tcp/sctp on DODGY bit removal after validatinggso_segs. Also moved the UDP header check into__udp_gso_segment(per Willem's suggestion).
Thanks
Quoted 12 lines · Willem de Bruijn
Quoted 10 lines · Yan Zhai
Commit
1fd54773c267("udp: allow header check for dodgyGSO_UDP_L4packets.") checks DODGY bit for UDP, but for packets that can be fed directly to the device aftergso_segsreset, it actually falls through to fragmentation:https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2WaDo28KzYDg+A@mail.gmail.com/
This change restores the expected behavior of
GSO_UDP_L4packets.
Quoted 8 lines
Quoted 3 lines
Fixes 1fd54773c267 ("udp: allow header check for dodgy GSO_UDP_L4 packets.")Suggested-by Willem de Bruijn <[email protected]>Signed-off-by Yan Zhai <[email protected]>Reviewed-by Willem de Bruijn <[email protected]>for next time: places hyperlinks in the block of tags at the bottom of the commit as "Link: ${URL}"
Good to learn, thanks!
--
Yan
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Thu, 13 Jul 2023 10:28:00 -0700 you wrote:
Commit
1fd54773c267("udp: allow header check for dodgyGSO_UDP_L4packets.") checks DODGY bit for UDP, but for packets that can be fed directly to the device aftergso_segsreset, it actually falls through to fragmentation:https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2WaDo28KzYDg+A@mail.gmail.com/
[...]
Here is the summary with links:
- [v2,net] gso: fix dodgy bit handling for GSO_UDP_L4
https://git.kernel.org/netdev/net/c/9840036786d9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html