Skip to content

Commit 03f16c5

Browse files
vincent-mailholmarckleinebudde
authored andcommitted
can: dev: can_restart: fix use after free bug
After calling netif_rx_ni(skb), dereferencing skb is unsafe. Especially, the can_frame cf which aliases skb memory is accessed after the netif_rx_ni() in: stats->rx_bytes += cf->len; Reordering the lines solves the issue. Fixes: 39549ee ("can: CAN Network device driver and Netlink interface") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vincent Mailhol <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 9c30ae8 commit 03f16c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/can/dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,11 @@ static void can_restart(struct net_device *dev)
592592

593593
cf->can_id |= CAN_ERR_RESTARTED;
594594

595-
netif_rx_ni(skb);
596-
597595
stats->rx_packets++;
598596
stats->rx_bytes += cf->len;
599597

598+
netif_rx_ni(skb);
599+
600600
restart:
601601
netdev_dbg(dev, "restarted\n");
602602
priv->can_stats.restarts++;

0 commit comments

Comments
 (0)