pull-request: can 2025-02-08
Subsystems (11)
Marc Kleine-Budde
maintainercover pull-request: can 2025-02-08
Hello netdev-team,
this is a pull request of 6 patches for net/master.
The first patch is by Reyders Morales and fixes a code example in the CAN ISO15765-2 documentation.
The next patch is contributed by Alexander Hölzl and fixes sending of J1939 messages with zero data length.
Fedor Pchelkin's patch for the ctucanfd driver adds a missing handling for an skb allocation error.
Krzysztof Kozlowski contributes a patch for the c_can driver to fix unbalanced runtime PM disable in error path.
The next patch is by Vincent Mailhol and fixes a NULL pointer dereference on udev->serial in the etas_es58x driver.
The patch is by Robin van der Gracht and fixes the handling for an skb allocation error.
regards,
Marc
---
The following changes since commit 1438f5d07b9a7afb15e1d0e26df04a6fd4e56a3c:
rtnetlink: fix netns leak with rtnl_setlink() (2025-02-06 17:17:44 -0800)
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.14-20250208
for you to fetch changes up to f7f0adfe64de08803990dc4cbecd2849c04e314a:
can: rockchip: rkcanfd_handle_rx_fifo_overflow_int(): bail out if skb cannot be allocated (2025-02-08 12:42:56 +0100)
----------------------------------------------------------------
linux-can-fixes-for-6.14-20250208
----------------------------------------------------------------
Alexander Hölzl (1):
can: j1939: j1939_sk_send_loop(): fix unable to send messages with data length zero
Fedor Pchelkin (1):
can: ctucanfd: handle skb allocation failure
Krzysztof Kozlowski (1):
can: c_can: fix unbalanced runtime PM disable in error path
Reyders Morales (1):
Documentation/networking: fix basic node example document ISO 15765-2
Robin van der Gracht (1):
can: rockchip: rkcanfd_handle_rx_fifo_overflow_int(): bail out if skb cannot be allocated
Vincent Mailhol (1):
can: etas_es58x: fix potential NULL pointer dereference on udev->serial
Documentation/networking/iso15765-2.rst | 4 ++-- drivers/net/can/c_can/c_can_platform.c | 5 +++-- drivers/net/can/ctucanfd/ctucanfd_base.c | 10 ++++++---- drivers/net/can/rockchip/rockchip_canfd-core.c | 2 +- drivers/net/can/usb/etas_es58x/es58x_devlink.c | 6 +++++- net/can/j1939/socket.c | 4 ++-- net/can/j1939/transport.c | 5 +++-- 7 files changed, 22 insertions(+), 14 deletions(-)
Marc Kleine-Budde
maintainerPATCH 1/6 Documentation/networking: fix basic node example document ISO 15765-2
From: Reyders Morales <[email protected]>
In the current struct sockaddr_can tp is member of can_addr. tp is not member of struct sockaddr_can.
--- Documentation/networking/iso15765-2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/networking/iso15765-2.rst +2 -2
@@ -369,8 +369,8 @@ to their default. addr.can_family = AF_CAN; addr.can_ifindex = if_nametoindex("can0"); - addr.tp.tx_id = 0x18DA42F1 | CAN_EFF_FLAG; - addr.tp.rx_id = 0x18DAF142 | CAN_EFF_FLAG; + addr.can_addr.tp.tx_id = 0x18DA42F1 | CAN_EFF_FLAG; + addr.can_addr.tp.rx_id = 0x18DAF142 | CAN_EFF_FLAG; ret = bind(s, (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0)
base-commit: 1438f5d07b9a7afb15e1d0e26df04a6fd4e56a3c
Signature · 1 line
2.47.2
Re: [PATCH net 1/6] Documentation/networking: fix basic node example document ISO 15765-2
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 5 lines · On Sat, 8 Feb 2025 12:45:14 +0100 you wrote:
From: Reyders Morales <[email protected]>
In the current struct
sockaddr_cantp is member ofcan_addr. tp is not member of structsockaddr_can.
Quoted 8 lines
Signed-off-by Reyders Morales <[email protected]>Reviewed-by Simon Horman <[email protected]>Acked-by Oliver Hartkopp <[email protected]>Fixes 67711e04254c ("Documentation: networking: document ISO 15765-2")Signed-off-by Marc Kleine-Budde <[email protected]>[...]
Here is the summary with links:
- [net,1/6] Documentation/networking: fix basic node example document ISO 15765-2
https://git.kernel.org/netdev/net/c/d0b197b6505f - [net,2/6] can: j1939: j1939_sk_send_loop(): fix unable to send messages with data length zero https://git.kernel.org/netdev/net/c/44de577e61ed - [net,3/6] can: ctucanfd: handle skb allocation failure https://git.kernel.org/netdev/net/c/9bd24927e3ee - [net,4/6] can: c_can: fix unbalanced runtime PM disable in error path https://git.kernel.org/netdev/net/c/257a2cd3eb57 - [net,5/6] can: etas_es58x: fix potential NULL pointer dereference on udev->serial https://git.kernel.org/netdev/net/c/a1ad2109ce41 - [net,6/6] can: rockchip: rkcanfd_handle_rx_fifo_overflow_int(): bail out if skb cannot be allocated https://git.kernel.org/netdev/net/c/f7f0adfe64de
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Marc Kleine-Budde
maintainerPATCH 2/6 can: j1939: j1939_sk_send_loop(): fix unable to send messages with data length zero
In reply to Marc Kleine-BuddeFrom: Alexander Hölzl <[email protected]>
The J1939 standard requires the transmission of messages of length 0.
For example proprietary messages are specified with a data length of 0 to 1785. The transmission of such messages is not possible. Sending results in no error being returned but no corresponding can frame being generated.
Enable the transmission of zero length J1939 messages. In order to facilitate this two changes are necessary:
1) If the transmission of a new message is requested from user space the message is segmented in j1939_sk_send_loop(). Let the segmentation take into account zero length messages, do not terminate immediately, queue the corresponding skb.
2) j1939_session_skb_get_by_offset() selects the next skb to transmit for a session. Take into account that there might be zero length skbs in the queue.
--- net/can/j1939/socket.c | 4 ++-- net/can/j1939/transport.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
net/can/j1939/socket.c +2 -2
@@ -1132,7 +1132,7 @@ static int j1939_sk_send_loop(struct j1939_priv *priv, struct sock *sk, todo_size = size; -while (todo_size) { + do { struct j1939_sk_buff_cb *skcb; segment_size = min_t(size_t, J1939_MAX_TP_PACKET_SIZE,
@@ -1177,7 +1177,7 @@ static int j1939_sk_send_loop(struct j1939_priv *priv, struct sock *sk, todo_size -= segment_size; session->total_queued_size += segment_size; - } + }while (todo_size);switch (ret) {case 0 :/* OK */
net/can/j1939/transport.c +3 -2
@@ -382,8 +382,9 @@ sk_buff *j1939_session_skb_get_by_offset(struct j1939_session *session, skb_queue_walk(&session->skb_queue, do_skb) { do_skcb =j1939_skb_to_cb (do_skb); -if (offset_start >= do_skcb->offset && - offset_start < (do_skcb->offset + do_skb->len)) { +if ((offset_start >= do_skcb->offset && + offset_start < (do_skcb->offset + do_skb->len)) || + (offset_start ==0 && do_skcb->offset ==0 && do_skb->len ==0 )) { skb = do_skb; } }
Signature · 1 line
2.47.2
Marc Kleine-Budde
maintainerPATCH 3/6 can: ctucanfd: handle skb allocation failure
In reply to Marc Kleine-BuddeFrom: Fedor Pchelkin <[email protected]>
If skb allocation fails, the pointer to struct can_frame is NULL. This is actually handled everywhere inside ctucan_err_interrupt() except for the only place.
Add the missed NULL check.
Found by Linux Verification Center (linuxtesting.org) with SVACE static analysis tool.
--- drivers/net/can/ctucanfd/ctucanfd_base.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/can/ctucanfd/ctucanfd_base.c +6 -4
@@ -867,10 +867,12 @@ static void ctucan_err_interrupt(struct net_device *ndev, u32 isr) }break ;case CAN_STATE_ERROR_ACTIVE : - cf->can_id |=CAN_ERR_CNT ; - cf->data[1 ] =CAN_ERR_CRTL_ACTIVE ; - cf->data[6 ] = bec.txerr; - cf->data[7 ] = bec.rxerr; +if (skb) { + cf->can_id |=CAN_ERR_CNT ; + cf->data[1 ] =CAN_ERR_CRTL_ACTIVE ; + cf->data[6 ] = bec.txerr; + cf->data[7 ] = bec.rxerr; + }break ;default : netdev_warn(ndev, "unhandled error state (%d:%s)!\n",
Signature · 1 line
2.47.2
Marc Kleine-Budde
maintainerPATCH 4/6 can: c_can: fix unbalanced runtime PM disable in error path
In reply to Marc Kleine-BuddeFrom: Krzysztof Kozlowski <[email protected]>
Runtime PM is enabled as one of the last steps of probe(), so all earlier gotos to "exit_free_device" label were not correct and were leading to unbalanced runtime PM disable depth.
--- drivers/net/can/c_can/c_can_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/can/c_can/c_can_platform.c +3 -2
@@ -385,15 +385,16 @@ static int c_can_plat_probe(struct platform_device *pdev)if (ret) {dev_err (&pdev->dev,"registering %s failed (err=%d)\n" ,KBUILD_MODNAME , ret); - goto exit_free_device; + goto exit_pm_runtime; }dev_info (&pdev->dev,"%s device registered (regs=%p, irq=%d)\n" ,KBUILD_MODNAME , priv->base, dev->irq);return 0 ; -exit_free_device: +exit_pm_runtime:pm_runtime_disable (priv->device); +exit_free_device:free_c_can_dev (dev); exit:dev_err (&pdev->dev,"probe failed\n" );
Signature · 1 line
2.47.2
Marc Kleine-Budde
maintainerPATCH 5/6 can: etas_es58x: fix potential NULL pointer dereference on udev->serial
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
The driver assumed that es58x_dev->udev->serial could never be NULL. While this is true on commercially available devices, an attacker could spoof the device identity providing a NULL USB serial number. That would trigger a NULL pointer dereference.
Add a check on es58x_dev->udev->serial before accessing it.
--- drivers/net/can/usb/etas_es58x/es58x_devlink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/can/usb/etas_es58x/es58x_devlink.c +5 -1
@@ -248,7 +248,11 @@ static int es58x_devlink_info_get(struct devlink *devlink,return ret; } -return devlink_info_serial_number_put (req, es58x_dev->udev->serial); +if (es58x_dev->udev->serial) + ret =devlink_info_serial_number_put (req, + es58x_dev->udev->serial); + +return ret; }const struct devlink_ops es58x_dl_ops = {
Signature · 1 line
2.47.2
Marc Kleine-Budde
maintainerPATCH 6/6 can: rockchip: rkcanfd_handle_rx_fifo_overflow_int(): bail out if skb cannot be allocated
In reply to Marc Kleine-BuddeFrom: Robin van der Gracht <[email protected]>
Fix NULL pointer check in rkcanfd_handle_rx_fifo_overflow_int() to bail out if skb cannot be allocated.
--- drivers/net/can/rockchip/rockchip_canfd-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/rockchip/rockchip_canfd-core.c +1 -1
@@ -622,7 +622,7 @@ rkcanfd_handle_rx_fifo_overflow_int(struct rkcanfd_priv *priv)netdev_dbg (priv->ndev,"RX-FIFO overflow\n" ); skb =rkcanfd_alloc_can_err_skb (priv, &cf, ×tamp); -if (skb) +if (!skb)return 0 ;rkcanfd_get_berr_counter_corrected (priv, &bec);
Signature · 1 line
2.47.2