Skip to contentSkip to conversation

net:fix up skbs delta_truesize in UDP GRO frag_list

PATCH New Lena Wang 1 participant 1 message Feb 25, 2022

Subsystems (2)
lore
Share & tools
lore

Lena Wang

author
#0 lore raw

PATCH 1/1 net:fix up skbs delta_truesize in UDP GRO frag_list

From: lena wang <[email protected]>

The truesize for a UDP GRO packet is added by main skb and skbs in main skb's frag_list:
skb_gro_receive_list

        p->truesize += skb->truesize;

When uncloning skb, it will call pskb_expand_head and trusesize for frag_list skbs may increase. This can occur when allocators uses __netdev_alloc_skb and not jump into __alloc_skb. This flow does not use ksize(len) to calculate truesize while pskb_expand_head uses. skb_segment_list
err = skb_unclone(nskb, GFP_ATOMIC);
pskb_expand_head

        if (!skb->sk || skb->destructor == sock_edemux)
                skb->truesize += size - osize;

If we uses increased truesize adding as delta_truesize, it will be larger than before and even larger than previous total truesize value if skbs in frag_list are abundant. The main skb truesize will become smaller and even a minus value or a huge value for an unsigned int parameter. Then the following memory check will drop this abnormal skb.

To avoid this error we should use the original truesize to segment the main skb.

---
 net/core/skbuff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/skbuff.c +1 -1
index 9d0388be..8b7356c 100644
@@ -3876,6 +3876,7 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,
 		list_skb = list_skb->next;
 
 		err = 0;
+		delta_truesize += nskb->truesize;
 		if (skb_shared(nskb)) {
 			tmp = skb_clone(nskb, GFP_ATOMIC);
 			if (tmp) {
@@ -3900,7 +3901,6 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,
 		tail = nskb;
 
 		delta_len += nskb->len;
-		delta_truesize += nskb->truesize;
 
 		skb_push(nskb, -skb_network_offset(nskb) + offset);
 
Signature · 1 line
1.9.1