pull-request: can 2025-09-23
Subsystems (7)
Marc Kleine-Budde
maintainercover pull-request: can 2025-09-23
Hello netdev-team,
this is a pull request of 7 patches for net/main.
The 1st patch is by Chen Yufeng and fixes a potential NULL pointer deref in the hi311x driver.
Duy Nguyen contributes a patch for the rcar_canfd driver to fix the controller mode setting.
The next 4 patches are by Vincent Mailhol and populate the ndo_change_mtu(( callback in the etas_es58x, hi311x, sun4i_can and mcba_usb driver to prevent buffer overflows.
Stéphane Grosjean's patch for the peak_usb driver fixes a shift-out-of-bounds issue.
regards,
Marc
---
The following changes since commit cbf658dd09419f1ef9de11b9604e950bdd5c170b:
Merge tag 'net-6.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2025-09-18 10:22:02 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-6.17-20250923
for you to fetch changes up to c443be70aaee42c2d1d251e0329e0a69dd96ae54:
can: peak_usb: fix shift-out-of-bounds issue (2025-09-19 19:17:37 +0200)
----------------------------------------------------------------
linux-can-fixes-for-6.17-20250923
----------------------------------------------------------------
Chen Yufeng (1):
can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled
Duy Nguyen (1):
can: rcar_canfd: Fix controller mode setting
Marc Kleine-Budde (1):
Merge patch series "can: populate ndo_change_mtu() to prevent buffer overflow"
Stéphane Grosjean (1):
can: peak_usb: fix shift-out-of-bounds issue
Vincent Mailhol (4):
can: etas_es58x: populate ndo_change_mtu() to prevent buffer overflow
can: hi311x: populate ndo_change_mtu() to prevent buffer overflow
can: sun4i_can: populate ndo_change_mtu() to prevent buffer overflow
can: mcba_usb: populate ndo_change_mtu() to prevent buffer overflow
drivers/net/can/rcar/rcar_canfd.c | 7 +++--- drivers/net/can/spi/hi311x.c | 34 +++++++++++++++------------- drivers/net/can/sun4i_can.c | 1 + drivers/net/can/usb/etas_es58x/es58x_core.c | 3 ++- drivers/net/can/usb/mcba_usb.c | 1 + drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 +- 6 files changed, 27 insertions(+), 21 deletions(-)
Marc Kleine-Budde
maintainerPATCH 1/7 can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled
From: Chen Yufeng <[email protected]>
This issue is similar to the vulnerability in the mcp251x driver, which was fixed in commit 03c427147b2d ("can: mcp251x: fix resume from sleep before interface was brought up").
In the hi311x driver, when the device resumes from sleep, the driver schedules priv->restart_work. However, if the network interface was not previously enabled, the priv->wq (workqueue) is not allocated and initialized, leading to a null pointer dereference.
To fix this, we move the allocation and initialization of the workqueue from the hi3110_open function to the hi3110_can_probe function. This ensures that the workqueue is properly initialized before it is used during device resume. And added logic to destroy the workqueue in the error handling paths of hi3110_can_probe and in the hi3110_can_remove function to prevent resource leaks.
--- drivers/net/can/spi/hi311x.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/net/can/spi/hi311x.c +17 -16
@@ -545,8 +545,6 @@ static int hi3110_stop(struct net_device *net) priv->force_quit =1 ;free_irq (spi->irq, priv); -destroy_workqueue (priv->wq); - priv->wq =NULL ;mutex_lock (&priv->hi3110_lock);
@@ -770,34 +768,23 @@ static int hi3110_open(struct net_device *net) goto out_close; } - priv->wq =alloc_workqueue ("hi3110_wq" ,WQ_FREEZABLE |WQ_MEM_RECLAIM , -0 ); -if (!priv->wq) { - ret = -ENOMEM ; - goto out_free_irq; - } -INIT_WORK (&priv->tx_work, hi3110_tx_work_handler); -INIT_WORK (&priv->restart_work, hi3110_restart_work_handler); - ret =hi3110_hw_reset (spi);if (ret) - goto out_free_wq; + goto out_free_irq; ret =hi3110_setup (net);if (ret) - goto out_free_wq; + goto out_free_irq; ret =hi3110_set_normal_mode (spi);if (ret) - goto out_free_wq; + goto out_free_irq;netif_wake_queue (net);mutex_unlock (&priv->hi3110_lock);return 0 ; - out_free_wq: -destroy_workqueue (priv->wq); out_free_irq:free_irq (spi->irq, priv);hi3110_hw_sleep (spi);
@@ -908,6 +895,15 @@ static int hi3110_can_probe(struct spi_device *spi)if (ret) goto out_clk; + priv->wq =alloc_workqueue ("hi3110_wq" ,WQ_FREEZABLE |WQ_MEM_RECLAIM , +0 ); +if (!priv->wq) { + ret = -ENOMEM ; + goto out_clk; + } +INIT_WORK (&priv->tx_work, hi3110_tx_work_handler); +INIT_WORK (&priv->restart_work, hi3110_restart_work_handler); + priv->spi = spi;mutex_init (&priv->hi3110_lock);
@@ -943,6 +939,8 @@ static int hi3110_can_probe(struct spi_device *spi)return 0 ; error_probe: +destroy_workqueue (priv->wq); + priv->wq =NULL ;hi3110_power_enable (priv->power,0 ); out_clk:
@@ -963,6 +961,9 @@ static void hi3110_can_remove(struct spi_device *spi)hi3110_power_enable (priv->power,0 ); +destroy_workqueue (priv->wq); + priv->wq =NULL ; +clk_disable_unprepare (priv->clk);free_candev (net);
base-commit: cbf658dd09419f1ef9de11b9604e950bdd5c170b
Signature · 1 line
2.51.0
Re: [PATCH net 1/7] can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled
This series was applied to netdev/net.git (main) by Marc Kleine-Budde <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Marc Kleine-Budde <[email protected]>:
Quoted 6 lines · On Tue, 23 Sep 2025 09:32:47 +0200 you wrote:
From: Chen Yufeng <[email protected]>
This issue is similar to the vulnerability in the
mcp251xdriver, which was fixed in commit03c427147b2d("can: mcp251x: fix resume from sleep before interface was brought up").
Quoted 6 lines
In the
hi311xdriver, when the device resumes from sleep, the driver schedulespriv->restart_work. However, if the network interface was not previously enabled, thepriv->wq(workqueue) is not allocated and initialized, leading to a null pointer dereference.[...]
Here is the summary with links:
- [net,1/7] can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled
https://git.kernel.org/netdev/net/c/6b6968084721 - [net,2/7] can: rcar_canfd: Fix controller mode setting https://git.kernel.org/netdev/net/c/5cff263606a1 - [net,3/7] can: etas_es58x: populate ndo_change_mtu() to prevent buffer overflow https://git.kernel.org/netdev/net/c/38c0abad45b1 - [net,4/7] can: hi311x: populate ndo_change_mtu() to prevent buffer overflow https://git.kernel.org/netdev/net/c/ac1c7656fa71 - [net,5/7] can: sun4i_can: populate ndo_change_mtu() to prevent buffer overflow https://git.kernel.org/netdev/net/c/61da0bd4102c - [net,6/7] can: mcba_usb: populate ndo_change_mtu() to prevent buffer overflow https://git.kernel.org/netdev/net/c/17c8d794527f - [net,7/7] can: peak_usb: fix shift-out-of-bounds issue https://git.kernel.org/netdev/net/c/c443be70aaee
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH net 1/7] can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled: manual merge
In reply to Marc Kleine-BuddeHello,
Quoted 11 lines · Marc Kleine-Budde
From: Chen Yufeng <[email protected]>
This issue is similar to the vulnerability in the
mcp251xdriver, which was fixed in commit03c427147b2d("can: mcp251x: fix resume from sleep before interface was brought up").In the
hi311xdriver, when the device resumes from sleep, the driver schedulespriv->restart_work. However, if the network interface was not previously enabled, thepriv->wq(workqueue) is not allocated and initialized, leading to a null pointer dereference.
Quoted 6 lines
To fix this, we move the allocation and initialization of the workqueue from the
hi3110_openfunction to thehi3110_can_probefunction. This ensures that the workqueue is properly initialized before it is used during device resume. And added logic to destroy the workqueue in the error handling paths ofhi3110_can_probeand in thehi3110_can_removefunction to prevent resource leaks.
FYI, we got a small conflict when merging 'net' in 'net-next' in the MPTCP tree due to this patch applied in 'net':
6b6968084721 ("can: hi311x: fix null pointer dereference when resuming
from sleep before interface was enabled")
and this one from 'net-next':
27ce71e1ce81 ("net: WQ_PERCPU added to alloc_workqueue users")
----- Generic Message -----
The best is to avoid conflicts between 'net' and 'net-next' trees but if they cannot be avoided when preparing patches, a note about how to fix them is much appreciated.
The conflict has been resolved on our side[1] and the resolution we suggest is attached to this email. Please report any issues linked to this conflict resolution as it might be used by others. If you worked on the mentioned patches, don't hesitate to ACK this conflict resolution.
---------------------------
Regarding this conflict, I simply added "WQ_PERCPU" flag to alloc_workqueue() in hi3110_can_probe() -- the new location after the modification in 'net' -- instead of in hi3110_open().
Rerere cache is available in [2].
Cheers,
Matt
1: https://github.com/multipath-tcp/mptcp_net-next/commit/4ef39a01f1f0
2: https://github.com/multipath-tcp/mptcp-upstream-rr-cache/commit/1a8b8
Signature · 1 line
Sponsored by the NGI0 Core fund.
drivers/net/can/spi/hi311x.c +0 -0
@@@ -909,6 -896,15 +896,16 @@@ static int hi3110_can_probe(struct spi_if (ret) goto out_clk; - priv->wq =alloc_workqueue ("hi3110_wq" ,WQ_FREEZABLE |WQ_MEM_RECLAIM , ++ priv->wq =alloc_workqueue ("hi3110_wq" , ++WQ_FREEZABLE |WQ_MEM_RECLAIM |WQ_PERCPU , + 0); +if (!priv->wq) { + ret = -ENOMEM ; + goto out_clk; + } +INIT_WORK (&priv->tx_work, hi3110_tx_work_handler); +INIT_WORK (&priv->restart_work, hi3110_restart_work_handler); + priv->spi = spi;mutex_init (&priv->hi3110_lock);
Marc Kleine-Budde
maintainerRe: [PATCH net 1/7] can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled: manual merge
Quoted 21 lines · Matthieu Baerts
Hello,
Quoted 11 lines · Marc Kleine-Budde
From: Chen Yufeng <[email protected]>
This issue is similar to the vulnerability in the
mcp251xdriver, which was fixed in commit03c427147b2d("can: mcp251x: fix resume from sleep before interface was brought up").In the
hi311xdriver, when the device resumes from sleep, the driver schedulespriv->restart_work. However, if the network interface was not previously enabled, thepriv->wq(workqueue) is not allocated and initialized, leading to a null pointer dereference.Quoted 6 lines
To fix this, we move the allocation and initialization of the workqueue from the
hi3110_openfunction to thehi3110_can_probefunction. This ensures that the workqueue is properly initialized before it is used during device resume. And added logic to destroy the workqueue in the error handling paths ofhi3110_can_probeand in thehi3110_can_removefunction to prevent resource leaks.
Quoted 2 lines
FYI, we got a small conflict when merging 'net' in 'net-next' in the MPTCP tree due to this patch applied in 'net':
Thanks for the heads up!
Quoted 17 lines
6b6968084721("can: hi311x: fix null pointer dereference when resuming
from sleep before interface was enabled")and this one from 'net-next':
27ce71e1ce81("net:WQ_PERCPUadded toalloc_workqueueusers")----- Generic Message -----
The best is to avoid conflicts between 'net' and 'net-next' trees but if they cannot be avoided when preparing patches, a note about how to fix them is much appreciated.
The conflict has been resolved on our side[1] and the resolution we suggest is attached to this email. Please report any issues linked to this conflict resolution as it might be used by others. If you worked on the mentioned patches, don't hesitate to ACK this conflict resolution.
---------------------------
Quoted 5 lines
Regarding this conflict, I simply added "
WQ_PERCPU" flag toalloc_workqueue()inhi3110_can_probe()-- the new location after the modification in 'net' -- instead of inhi3110_open().Rerere cache is available in [2].
Looks good to me!
Thanks,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Marc Kleine-Budde
maintainerPATCH 2/7 can: rcar_canfd: Fix controller mode setting
In reply to Marc Kleine-BuddeFrom: Duy Nguyen <[email protected]>
Driver configures register to choose controller mode before setting all channels to reset mode leading to failure. The patch corrects operation of mode setting.
--- drivers/net/can/rcar/rcar_canfd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +4 -3
@@ -823,9 +823,6 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)/* Reset Global error flags */ rcar_canfd_write (gpriv->base,RCANFD_GERFL ,0x0 ); -/* Set the controller into appropriate mode */ -rcar_canfd_set_mode (gpriv); -/* Transition all Channels to reset mode */ for_each_set_bit (ch, &gpriv->channels_mask, gpriv->info->max_channels) { rcar_canfd_clear_bit(gpriv->base,
@@ -844,6 +841,10 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)return err; } } + +/* Set the controller into appropriate mode */ +rcar_canfd_set_mode (gpriv); +return 0 ; }
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 3/7 can: etas_es58x: populate ndo_change_mtu() to prevent buffer overflow
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Sending an PF_PACKET allows to bypass the CAN framework logic and to directly reach the xmit() function of a CAN driver. The only check which is performed by the PF_PACKET framework is to make sure that skb->len fits the interface's MTU.
Unfortunately, because the etas_es58x driver does not populate its net_device_ops->ndo_change_mtu(), it is possible for an attacker to configure an invalid MTU by doing, for example:
$ ip link set can0 mtu 9999
After doing so, the attacker could open a PF_PACKET socket using the ETH_P_CANXL protocol:
socket(PF_PACKET, SOCK_RAW, htons(ETH_P_CANXL));
to inject a malicious CAN XL frames. For example:
struct canxl_frame frame = {
.flags = 0xff,
.len = 2048,
};The CAN drivers' xmit() function are calling can_dev_dropped_skb() to check that the skb is valid, unfortunately under above conditions, the malicious packet is able to go through can_dev_dropped_skb() checks:
1. the skb->protocol is set to ETH_P_CANXL which is valid (the function does not check the actual device capabilities).
2. the length is a valid CAN XL length.
And so, es58x_start_xmit() receives a CAN XL frame which it is not able to correctly handle and will thus misinterpret it as a CAN(FD) frame.
This can result in a buffer overflow. For example, using the es581.4 variant, the frame will be dispatched to es581_4_tx_can_msg(), go through the last check at the beginning of this function:
if (can_is_canfd_skb(skb)) return -EMSGSIZE;
and reach this line:
memcpy(tx_can_msg->data, cf->data, cf->len);
Here, cf->len corresponds to the flags field of the CAN XL frame. In our previous example, we set canxl_frame->flags to 0xff. Because the maximum expected length is 8, a buffer overflow of 247 bytes occurs!
Populate net_device_ops->ndo_change_mtu() to ensure that the interface's MTU can not be set to anything bigger than CAN_MTU or CANFD_MTU (depending on the device capabilities). By fixing the root cause, this prevents the buffer overflow.
--- drivers/net/can/usb/etas_es58x/es58x_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/can/usb/etas_es58x/es58x_core.c +2 -1
@@ -7,7 +7,7 @@* * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. -* Copyright (c) 2020-2022 Vincent Mailhol <[email protected]> +* Copyright (c) 2020-2025 Vincent Mailhol <[email protected]> */ #include <linux/unaligned.h>
@@ -1977,6 +1977,7 @@ static const struct net_device_ops es58x_netdev_ops = { .ndo_stop = es58x_stop, .ndo_start_xmit = es58x_start_xmit, .ndo_eth_ioctl = can_eth_ioctl_hwts, + .ndo_change_mtu = can_change_mtu, };static const struct ethtool_ops es58x_ethtool_ops = {
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 4/7 can: hi311x: populate ndo_change_mtu() to prevent buffer overflow
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Sending an PF_PACKET allows to bypass the CAN framework logic and to directly reach the xmit() function of a CAN driver. The only check which is performed by the PF_PACKET framework is to make sure that skb->len fits the interface's MTU.
Unfortunately, because the sun4i_can driver does not populate its net_device_ops->ndo_change_mtu(), it is possible for an attacker to configure an invalid MTU by doing, for example:
$ ip link set can0 mtu 9999
After doing so, the attacker could open a PF_PACKET socket using the ETH_P_CANXL protocol:
socket(PF_PACKET, SOCK_RAW, htons(ETH_P_CANXL))
to inject a malicious CAN XL frames. For example:
struct canxl_frame frame = {
.flags = 0xff,
.len = 2048,
};The CAN drivers' xmit() function are calling can_dev_dropped_skb() to check that the skb is valid, unfortunately under above conditions, the malicious packet is able to go through can_dev_dropped_skb() checks:
1. the skb->protocol is set to ETH_P_CANXL which is valid (the function does not check the actual device capabilities).
2. the length is a valid CAN XL length.
And so, hi3110_hard_start_xmit() receives a CAN XL frame which it is not able to correctly handle and will thus misinterpret it as a CAN frame. The driver will consume frame->len as-is with no further checks.
This can result in a buffer overflow later on in hi3110_hw_tx() on this line:
memcpy(buf + HI3110_FIFO_EXT_DATA_OFF, frame->data, frame->len);
Here, frame->len corresponds to the flags field of the CAN XL frame. In our previous example, we set canxl_frame->flags to 0xff. Because the maximum expected length is 8, a buffer overflow of 247 bytes occurs!
Populate net_device_ops->ndo_change_mtu() to ensure that the interface's MTU can not be set to anything bigger than CAN_MTU. By fixing the root cause, this prevents the buffer overflow.
--- drivers/net/can/spi/hi311x.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/spi/hi311x.c +1 -0
@@ -799,6 +799,7 @@ static const struct net_device_ops hi3110_netdev_ops = { .ndo_open = hi3110_open, .ndo_stop = hi3110_stop, .ndo_start_xmit = hi3110_hard_start_xmit, + .ndo_change_mtu = can_change_mtu, };static const struct ethtool_ops hi3110_ethtool_ops = {
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 5/7 can: sun4i_can: populate ndo_change_mtu() to prevent buffer overflow
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Sending an PF_PACKET allows to bypass the CAN framework logic and to directly reach the xmit() function of a CAN driver. The only check which is performed by the PF_PACKET framework is to make sure that skb->len fits the interface's MTU.
Unfortunately, because the sun4i_can driver does not populate its net_device_ops->ndo_change_mtu(), it is possible for an attacker to configure an invalid MTU by doing, for example:
$ ip link set can0 mtu 9999
After doing so, the attacker could open a PF_PACKET socket using the ETH_P_CANXL protocol:
socket(PF_PACKET, SOCK_RAW, htons(ETH_P_CANXL))
to inject a malicious CAN XL frames. For example:
struct canxl_frame frame = {
.flags = 0xff,
.len = 2048,
};The CAN drivers' xmit() function are calling can_dev_dropped_skb() to check that the skb is valid, unfortunately under above conditions, the malicious packet is able to go through can_dev_dropped_skb() checks:
1. the skb->protocol is set to ETH_P_CANXL which is valid (the function does not check the actual device capabilities).
2. the length is a valid CAN XL length.
And so, sun4ican_start_xmit() receives a CAN XL frame which it is not able to correctly handle and will thus misinterpret it as a CAN frame.
This can result in a buffer overflow. The driver will consume cf->len as-is with no further checks on this line:
dlc = cf->len;
Here, cf->len corresponds to the flags field of the CAN XL frame. In our previous example, we set canxl_frame->flags to 0xff. Because the maximum expected length is 8, a buffer overflow of 247 bytes occurs a couple line below when doing:
for (i = 0; i < dlc; i++) writel(cf->data[i], priv->base + (dreg + i * 4));
Populate net_device_ops->ndo_change_mtu() to ensure that the interface's MTU can not be set to anything bigger than CAN_MTU. By fixing the root cause, this prevents the buffer overflow.
--- drivers/net/can/sun4i_can.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/sun4i_can.c +1 -0
@@ -768,6 +768,7 @@ static const struct net_device_ops sun4ican_netdev_ops = { .ndo_open = sun4ican_open, .ndo_stop = sun4ican_close, .ndo_start_xmit = sun4ican_start_xmit, + .ndo_change_mtu = can_change_mtu, };static const struct ethtool_ops sun4ican_ethtool_ops = {
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 6/7 can: mcba_usb: populate ndo_change_mtu() to prevent buffer overflow
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Sending an PF_PACKET allows to bypass the CAN framework logic and to directly reach the xmit() function of a CAN driver. The only check which is performed by the PF_PACKET framework is to make sure that skb->len fits the interface's MTU.
Unfortunately, because the mcba_usb driver does not populate its net_device_ops->ndo_change_mtu(), it is possible for an attacker to configure an invalid MTU by doing, for example:
$ ip link set can0 mtu 9999
After doing so, the attacker could open a PF_PACKET socket using the ETH_P_CANXL protocol:
socket(PF_PACKET, SOCK_RAW, htons(ETH_P_CANXL))
to inject a malicious CAN XL frames. For example:
struct canxl_frame frame = {
.flags = 0xff,
.len = 2048,
};The CAN drivers' xmit() function are calling can_dev_dropped_skb() to check that the skb is valid, unfortunately under above conditions, the malicious packet is able to go through can_dev_dropped_skb() checks:
1. the skb->protocol is set to ETH_P_CANXL which is valid (the function does not check the actual device capabilities).
2. the length is a valid CAN XL length.
And so, mcba_usb_start_xmit() receives a CAN XL frame which it is not able to correctly handle and will thus misinterpret it as a CAN frame.
This can result in a buffer overflow. The driver will consume cf->len as-is with no further checks on these lines:
usb_msg.dlc = cf->len; memcpy(usb_msg.data, cf->data, usb_msg.dlc);
Here, cf->len corresponds to the flags field of the CAN XL frame. In our previous example, we set canxl_frame->flags to 0xff. Because the maximum expected length is 8, a buffer overflow of 247 bytes occurs!
Populate net_device_ops->ndo_change_mtu() to ensure that the interface's MTU can not be set to anything bigger than CAN_MTU. By fixing the root cause, this prevents the buffer overflow.
--- drivers/net/can/usb/mcba_usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/usb/mcba_usb.c +1 -0
@@ -761,6 +761,7 @@ static const struct net_device_ops mcba_netdev_ops = { .ndo_open = mcba_usb_open, .ndo_stop = mcba_usb_close, .ndo_start_xmit = mcba_usb_start_xmit, + .ndo_change_mtu = can_change_mtu, };static const struct ethtool_ops mcba_ethtool_ops = {
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 7/7 can: peak_usb: fix shift-out-of-bounds issue
In reply to Marc Kleine-BuddeFrom: Stéphane Grosjean <[email protected]>
Explicitly uses a 64-bit constant when the number of bits used for its shifting is 32 (which is the case for PC CAN FD interfaces supported by this driver).
--- drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/peak_usb/pcan_usb_core.c +1 -1
@@ -111,7 +111,7 @@ void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now)u32 delta_ts = time_ref->ts_dev_2 - time_ref->ts_dev_1;if (time_ref->ts_dev_2 < time_ref->ts_dev_1) - delta_ts &= (1 << time_ref->adapter->ts_used_bits) -1 ; + delta_ts &= (1ULL << time_ref->adapter->ts_used_bits) -1 ; time_ref->ts_total += delta_ts; }
Signature · 1 line
2.51.0