Skip to content

Commit b806b26

Browse files
committed
can: peak_usb: fix use after free bugs
jira VULN-64816 cve CVE-2021-47670 commit-author Vincent Mailhol <mailhol.vincent@wanadoo.fr> commit 50aca89 After calling peak_usb_netif_rx_ni(skb), dereferencing skb is unsafe. Especially, the can_frame cf which aliases skb memory is accessed after the peak_usb_netif_rx_ni(). Reordering the lines solves the issue. Fixes: 0a25e1f ("can: peak_usb: add support for PEAK new CANFD USB adapters") Link: https://lore.kernel.org/r/20210120114137.200019-4-mailhol.vincent@wanadoo.fr Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> (cherry picked from commit 50aca89) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 930f427 commit b806b26

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/can/usb/peak_usb/pcan_usb_fd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,11 @@ static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if,
520520
else
521521
memcpy(cfd->data, rm->d, cfd->len);
522522

523-
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));
524-
525523
netdev->stats.rx_packets++;
526524
netdev->stats.rx_bytes += cfd->len;
527525

526+
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));
527+
528528
return 0;
529529
}
530530

@@ -586,11 +586,11 @@ static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if,
586586
if (!skb)
587587
return -ENOMEM;
588588

589-
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));
590-
591589
netdev->stats.rx_packets++;
592590
netdev->stats.rx_bytes += cf->can_dlc;
593591

592+
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));
593+
594594
return 0;
595595
}
596596

0 commit comments

Comments
 (0)