Skip to content

Commit

Permalink
Merge tag 'linux-can-fixes-for-5.11-20210120' of git://git.kernel.org…
Browse files Browse the repository at this point in the history
…/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
linux-can-fixes-for-5.11-20210120

All three patches are by Vincent Mailhol and fix a potential use after free bug
in the CAN device infrastructure, the vxcan driver, and the peak_usk driver. In
the TX-path the skb is used to read from after it was passed to the networking
stack with netif_rx_ni().

* tag 'linux-can-fixes-for-5.11-20210120' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can:
  can: peak_usb: fix use after free bugs
  can: vxcan: vxcan_xmit: fix use after free bug
  can: dev: can_restart: fix use after free bug
====================

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
kuba-moo committed Jan 20, 2021
2 parents 0c630a6 + 50aca89 commit 535d315
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions drivers/net/can/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,11 @@ static void can_restart(struct net_device *dev)

cf->can_id |= CAN_ERR_RESTARTED;

netif_rx_ni(skb);

stats->rx_packets++;
stats->rx_bytes += cf->len;

netif_rx_ni(skb);

restart:
netdev_dbg(dev, "restarted\n");
priv->can_stats.restarts++;
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/can/usb/peak_usb/pcan_usb_fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if,
else
memcpy(cfd->data, rm->d, cfd->len);

peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));

netdev->stats.rx_packets++;
netdev->stats.rx_bytes += cfd->len;

peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));

return 0;
}

Expand Down Expand Up @@ -580,11 +580,11 @@ static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if,
if (!skb)
return -ENOMEM;

peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));

netdev->stats.rx_packets++;
netdev->stats.rx_bytes += cf->len;

peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));

return 0;
}

Expand Down
6 changes: 4 additions & 2 deletions drivers/net/can/vxcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static netdev_tx_t vxcan_xmit(struct sk_buff *skb, struct net_device *dev)
struct net_device *peer;
struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
struct net_device_stats *peerstats, *srcstats = &dev->stats;
u8 len;

if (can_dropped_invalid_skb(dev, skb))
return NETDEV_TX_OK;
Expand All @@ -61,12 +62,13 @@ static netdev_tx_t vxcan_xmit(struct sk_buff *skb, struct net_device *dev)
skb->dev = peer;
skb->ip_summed = CHECKSUM_UNNECESSARY;

len = cfd->len;
if (netif_rx_ni(skb) == NET_RX_SUCCESS) {
srcstats->tx_packets++;
srcstats->tx_bytes += cfd->len;
srcstats->tx_bytes += len;
peerstats = &peer->stats;
peerstats->rx_packets++;
peerstats->rx_bytes += cfd->len;
peerstats->rx_bytes += len;
}

out_unlock:
Expand Down

0 comments on commit 535d315

Please sign in to comment.