Skip to content

Commit 9baee04

Browse files
hartkoppsashalevin
authored andcommitted
can: add missing initialisations in CAN related skbuffs
[ Upstream commit 9694390 ] 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 <austin@peloton-tech.com> Reported-by: Daniel Steer <daniel.steer@mclaren.com> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 24cc23d commit 9baee04

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎drivers/net/can/dev.c‎

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

503+
skb_reset_mac_header(skb);
504+
skb_reset_network_header(skb);
505+
skb_reset_transport_header(skb);
506+
503507
can_skb_reserve(skb);
504508
can_skb_prv(skb)->ifindex = dev->ifindex;
505509

@@ -524,6 +528,10 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
524528
skb->pkt_type = PACKET_BROADCAST;
525529
skb->ip_summed = CHECKSUM_UNNECESSARY;
526530

531+
skb_reset_mac_header(skb);
532+
skb_reset_network_header(skb);
533+
skb_reset_transport_header(skb);
534+
527535
can_skb_reserve(skb);
528536
can_skb_prv(skb)->ifindex = dev->ifindex;
529537

‎net/can/af_can.c‎

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

265+
skb->ip_summed = CHECKSUM_UNNECESSARY;
266+
267+
skb_reset_mac_header(skb);
265268
skb_reset_network_header(skb);
266269
skb_reset_transport_header(skb);
267270

0 commit comments

Comments
 (0)