Skip to content

Commit 1b3b2d9

Browse files
edumazetkuba-moo
authored andcommitted
net: usb: smsc75xx: stop lying about skb->truesize
Some usb drivers try to set small skb->truesize and break core networking stacks. In this patch, I removed one of the skb->truesize override. I also replaced one skb_clone() by an allocation of a fresh and small skb, to get minimally sized skbs, like we did in commit 1e2c611 ("net: cdc_ncm: reduce skb truesize in rx path") and 4ce62d5 ("net: usb: ax88179_178a: stop lying about skb->truesize") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Steve Glendinning <steve.glendinning@shawell.net> Link: https://lore.kernel.org/r/20240506142358.3657918-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9aad6e4 commit 1b3b2d9

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/net/usb/smsc75xx.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,27 +2234,23 @@ static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
22342234
rx_cmd_b);
22352235

22362236
skb_trim(skb, skb->len - 4); /* remove fcs */
2237-
skb->truesize = size + sizeof(struct sk_buff);
22382237

22392238
return 1;
22402239
}
22412240

2242-
ax_skb = skb_clone(skb, GFP_ATOMIC);
2241+
/* Use "size - 4" to remove fcs */
2242+
ax_skb = netdev_alloc_skb_ip_align(dev->net, size - 4);
22432243
if (unlikely(!ax_skb)) {
22442244
netdev_warn(dev->net, "Error allocating skb\n");
22452245
return 0;
22462246
}
22472247

2248-
ax_skb->len = size;
2249-
ax_skb->data = packet;
2250-
skb_set_tail_pointer(ax_skb, size);
2248+
skb_put(ax_skb, size - 4);
2249+
memcpy(ax_skb->data, packet, size - 4);
22512250

22522251
smsc75xx_rx_csum_offload(dev, ax_skb, rx_cmd_a,
22532252
rx_cmd_b);
22542253

2255-
skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */
2256-
ax_skb->truesize = size + sizeof(struct sk_buff);
2257-
22582254
usbnet_skb_return(dev, ax_skb);
22592255
}
22602256

0 commit comments

Comments
 (0)