Skip to contentSkip to conversation

net: add missing check for TCP fraglist GRO

PATCH In review Felix Fietkau 4 participants 6 messages May 7, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: add missing check for TCP fraglist GRO

It turns out that the existing checks do not guarantee that the skb can be pulled up to the GRO offset. When using the usb r8152 network driver with GRO fraglist, the BUG() in __skb_pull is often triggered.
Fix the crash by adding the missing check.

Fixes 8d95dc474f85 ("net: add code for TCP fraglist GRO")
---
 net/ipv4/tcp_offload.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_offload.c +1 -0
index c90704befd7b..a71d2e623f0c 100644
@@ -353,6 +353,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
 		flush |= (__force int)(flags ^ tcp_flag_word(th2));
 		flush |= skb->ip_summed != p->ip_summed;
 		flush |= skb->csum_level != p->csum_level;
+		flush |= !pskb_may_pull(skb, skb_gro_offset(skb));
 		flush |= NAPI_GRO_CB(p)->count >= 64;
 
 		if (flush || skb_gro_receive_list(p, skb))
Signature · 1 line
2.44.0
#1 lore raw
Quoted 7 lines

----------------------------------------------------------------------
It turns out that the existing checks do not guarantee that the skb can be pulled up to the GRO offset. When using the usb r8152 network driver with GRO fraglist, the BUG() in __skb_pull is often triggered.
Fix the crash by adding the missing check.

Fixes 8d95dc474f85 ("net: add code for TCP fraglist GRO")

[Suman] Since this is a fix, this should be pushed to "net".

Quoted 21 lines

---
net/ipv4/tcp_offload.c | 1 +

1 file changed, 1 insertion(+)
net/ipv4/tcp_offload.c index renamed from net/ipv4/tcp_offload.c +0 -0

c90704befd7b..a71d2e623f0c 100644

net/ipv4/tcp_offload.c +1 -0
@@ -353,6 +353,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head,
 struct sk_buff *skb,
 		flush |= (__force int)(flags ^ tcp_flag_word(th2));
 		flush |= skb->ip_summed != p->ip_summed;
 		flush |= skb->csum_level != p->csum_level;
+		flush |= !pskb_may_pull(skb, skb_gro_offset(skb));
 		flush |= NAPI_GRO_CB(p)->count >= 64;
 
		if (flush || skb_gro_receive_list(p, skb))

--
2.44.0

#2 lore raw
Quoted 8 lines · Suman Ghosh
Quoted 7 lines

----------------------------------------------------------------------
It turns out that the existing checks do not guarantee that the skb can be pulled up to the GRO offset. When using the usb r8152 network driver with GRO fraglist, the BUG() in __skb_pull is often triggered.
Fix the crash by adding the missing check.

Fixes 8d95dc474f85 ("net: add code for TCP fraglist GRO")

[Suman] Since this is a fix, this should be pushed to "net".

No, it is fixing a commit that was just pulled into -next.

- Felix

#3 lore raw
Quoted 5 lines

[Suman] Since this is a fix, this should be pushed to "net".

No, it is fixing a commit that was just pulled into -next.

- Felix

[Suman] Got it. Thank you.

Reviewed-by
#4 lore raw
In reply to Suman Ghosh
Quoted 9 lines · Suman Ghosh
Quoted 7 lines

----------------------------------------------------------------------
It turns out that the existing checks do not guarantee that the skb can be pulled up to the GRO offset. When using the usb r8152 network driver with GRO fraglist, the BUG() in __skb_pull is often triggered.
Fix the crash by adding the missing check.

Fixes 8d95dc474f85 ("net: add code for TCP fraglist GRO")

[Suman] Since this is a fix, this should be pushed to "net".

The referenced patch has only landed in net-next yet.

Quoted 1 line
Quoted 1 line
Quoted 4 lines
Quoted 4 lines

---
net/ipv4/tcp_offload.c | 1 +

1 file changed, 1 insertion(+)
Quoted 11 lines

net/ipv4/tcp_offload.c struct sk_buff *tcp_gro_receive(struct list_head *head, · line 358

Quoted 11 lines
net/ipv4/tcp_offload.c index renamed from net/ipv4/tcp_offload.c +0 -0

c90704befd7b..a71d2e623f0c 100644

net/ipv4/tcp_offload.c +1 -0
@@ -353,6 +353,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head,
 struct sk_buff *skb,
 		flush |= (__force int)(flags ^ tcp_flag_word(th2));
 		flush |= skb->ip_summed != p->ip_summed;
 		flush |= skb->csum_level != p->csum_level;
+		flush |= !pskb_may_pull(skb, skb_gro_offset(skb));
 		flush |= NAPI_GRO_CB(p)->count >= 64;

The same check already exists in udp_gro_receive, which has for longer been calling skb_gro_receive_list:

       if (!pskb_may_pull(skb, skb_gro_offset(skb))) {
               NAPI_GRO_CB(skb)->flush = 1;
               return NULL;
       }

Alternatively it would make sense to deduplicate the check and move it to skb_gro_receive_list itself, before

        skb_pull(skb, skb_gro_offset(skb));
#5 lore raw
In reply to Felix Fietkau
Quoted 4 lines · Felix Fietkau

It turns out that the existing checks do not guarantee that the skb can be pulled up to the GRO offset. When using the usb r8152 network driver with GRO fraglist, the BUG() in __skb_pull is often triggered.

Why is it crashing ? I would expect tcp_gro_pull_header() to perform this early.

Please include a stack trace.

Quoted 23 lines

Fix the crash by adding the missing check.

Fixes 8d95dc474f85 ("net: add code for TCP fraglist GRO")
---
 net/ipv4/tcp_offload.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_offload.c +1 -1
index c90704befd7b..a71d2e623f0c 100644
@@ -353,6 +353,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
                flush |= (__force int)(flags ^ tcp_flag_word(th2));
                flush |= skb->ip_summed != p->ip_summed;
                flush |= skb->csum_level != p->csum_level;
+               flush |= !pskb_may_pull(skb, skb_gro_offset(skb));
                flush |= NAPI_GRO_CB(p)->count >= 64;
 
                if (flush || skb_gro_receive_list(p, skb))
--

2.44.0