Skip to content

Commit 9694390

Browse files
hartkoppmarckleinebudde
authored andcommitted
can: add missing initialisations in CAN related skbuffs
When accessing CAN network interfaces with AF_PACKET sockets e.g. by dhclient this can lead to a skb_under_panic due to missing skb initialisations. Add the missing initialisations at the CAN skbuff creation times on driver level (rx path) and in the network layer (tx path). Reported-by: Austin Schuh <[email protected]> Reported-by: Daniel Steer <[email protected]> Signed-off-by: Oliver Hartkopp <[email protected]> Cc: linux-stable <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent c247f05 commit 9694390

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

drivers/net/can/dev.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,10 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
579579
skb->pkt_type = PACKET_BROADCAST;
580580
skb->ip_summed = CHECKSUM_UNNECESSARY;
581581

582+
skb_reset_mac_header(skb);
583+
skb_reset_network_header(skb);
584+
skb_reset_transport_header(skb);
585+
582586
can_skb_reserve(skb);
583587
can_skb_prv(skb)->ifindex = dev->ifindex;
584588

@@ -603,6 +607,10 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
603607
skb->pkt_type = PACKET_BROADCAST;
604608
skb->ip_summed = CHECKSUM_UNNECESSARY;
605609

610+
skb_reset_mac_header(skb);
611+
skb_reset_network_header(skb);
612+
skb_reset_transport_header(skb);
613+
606614
can_skb_reserve(skb);
607615
can_skb_prv(skb)->ifindex = dev->ifindex;
608616

net/can/af_can.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ int can_send(struct sk_buff *skb, int loop)
259259
goto inval_skb;
260260
}
261261

262+
skb->ip_summed = CHECKSUM_UNNECESSARY;
263+
264+
skb_reset_mac_header(skb);
262265
skb_reset_network_header(skb);
263266
skb_reset_transport_header(skb);
264267

0 commit comments

Comments
 (0)