pull-request: can 2025-09-10
Subsystems (10)
Marc Kleine-Budde
maintainercover pull-request: can 2025-09-10
Hello netdev-team,
this is a pull request of 7 patches for net/main, it supersedes linux-can-fixes-for-6.17-20250909.
The 1st patch is by Alex Tran and fixes the Documentation of the struct bcm_msg_head.
Davide Caratti's patch enabled the VCAN driver as a module for the Linux self tests.
Tetsuo Handa contributes 3 patches that fix various problems in the CAN j1939 protocol.
Anssi Hannula's patch fixes a potential use-after-free in the xilinx_can driver.
Geert Uytterhoeven's patch fixes the rcan_can's suspend to RAM on R-Car Gen3 using PSCI.
regards,
Marc
---
The following changes since commit d3b28612bc5500133260aaf36794a0a0c287d61b:
net: phy: NXP_TJA11XX: Update Kconfig with TJA1102 support (2025-09-08 18:24:19 -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-20250910
for you to fetch changes up to 5c793afa07da6d2d4595f6c73a2a543a471bb055:
can: rcar_can: rcar_can_resume(): fix s2ram with PSCI (2025-09-10 17:12:05 +0200)
----------------------------------------------------------------
linux-can-fixes-for-6.17-20250910
----------------------------------------------------------------
Alex Tran (1):
docs: networking: can: change bcm_msg_head frames member to support flexible array
Anssi Hannula (1):
can: xilinx_can: xcan_write_frame(): fix use-after-free of transmitted SKB
Davide Caratti (1):
selftests: can: enable CONFIG_CAN_VCAN as a module
Geert Uytterhoeven (1):
can: rcar_can: rcar_can_resume(): fix s2ram with PSCI
Tetsuo Handa (3):
can: j1939: implement NETDEV_UNREGISTER notification handler
can: j1939: j1939_sk_bind(): call j1939_priv_put() immediately when j1939_local_ecu_get() failed
can: j1939: j1939_local_ecu_get(): undo increment when j1939_local_ecu_get() failsDocumentation/networking/can.rst | 2 +- drivers/net/can/rcar/rcar_can.c | 8 +----- drivers/net/can/xilinx_can.c | 16 +++++------ net/can/j1939/bus.c | 5 +++- net/can/j1939/j1939-priv.h | 1 + net/can/j1939/main.c | 3 ++ net/can/j1939/socket.c | 52 ++++++++++++++++++++++++++++++++++ tools/testing/selftests/net/can/config | 3 ++ 8 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 tools/testing/selftests/net/can/config
Marc Kleine-Budde
maintainerPATCH 1/7 docs: networking: can: change bcm_msg_head frames member to support flexible array
From: Alex Tran <[email protected]>
The documentation of the 'bcm_msg_head' struct does not match how it is defined in 'bcm.h'. Changed the frames member to a flexible array, matching the definition in the header file.
See commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members")
--- Documentation/networking/can.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/networking/can.rst +1 -1
@@ -742,7 +742,7 @@ The broadcast manager sends responses to user space in the same form: struct timeval ival1, ival2; /* count and subsequent interval */ canid_t can_id; /* unique can_id for task */ __u32 nframes; /* number of can_frames following */ - struct can_frame frames[0]; + struct can_frame frames[]; }; The aligned payload 'frames' uses the same basic CAN frame structure defined
base-commit: d3b28612bc5500133260aaf36794a0a0c287d61b
Signature · 1 line
2.51.0
Re: [PATCH net 1/7] docs: networking: can: change bcm_msg_head frames member to support flexible array
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 10 lines · On Wed, 10 Sep 2025 18:20:21 +0200 you wrote:
From: Alex Tran <[email protected]>
The documentation of the '
bcm_msg_head' struct does not match how it is defined in 'bcm.h'. Changed the frames member to a flexible array, matching the definition in the header file.See commit
94dfc73e7cf4("treewide: uapi: Replace zero-length arrays with flexible-array members")[...]
Here is the summary with links:
- [net,1/7] docs: networking: can: change bcm_msg_head frames member to support flexible array
https://git.kernel.org/netdev/net/c/641427d5bf90 - [net,2/7] selftests: can: enable CONFIG_CAN_VCAN as a module https://git.kernel.org/netdev/net/c/d013ebc3499f - [net,3/7] can: j1939: implement NETDEV_UNREGISTER notification handler https://git.kernel.org/netdev/net/c/7fcbe5b2c6a4 - [net,4/7] can: j1939: j1939_sk_bind(): call j1939_priv_put() immediately when j1939_local_ecu_get() failed https://git.kernel.org/netdev/net/c/f214744c8a27 - [net,5/7] can: j1939: j1939_local_ecu_get(): undo increment when j1939_local_ecu_get() fails https://git.kernel.org/netdev/net/c/06e02da29f6f - [net,6/7] can: xilinx_can: xcan_write_frame(): fix use-after-free of transmitted SKB https://git.kernel.org/netdev/net/c/ef79f00be72b - [net,7/7] can: rcar_can: rcar_can_resume(): fix s2ram with PSCI https://git.kernel.org/netdev/net/c/5c793afa07da
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/7 selftests: can: enable CONFIG_CAN_VCAN as a module
In reply to Marc Kleine-BuddeFrom: Davide Caratti <[email protected]>
A proper kernel configuration for running kselftest can be obtained with:
$ yes | make kselftest-merge
Build of 'vcan' driver is currently missing, while the other required knobs are already there because of net/link_netns.py [1]. Add a config file in selftests/net/can to store the minimum set of kconfig needed for CAN selftests.
[1] https://patch.msgid.link/[email protected]
--- tools/testing/selftests/net/can/config | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tools/testing/selftests/net/can/config
tools/testing/selftests/net/can/config new file +3 -0
@@ -0,0 +1,3 @@ +CONFIG_CAN=m +CONFIG_CAN_DEV=m +CONFIG_CAN_VCAN=m
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 3/7 can: j1939: implement NETDEV_UNREGISTER notification handler
In reply to Marc Kleine-BuddeFrom: Tetsuo Handa <[email protected]>
syzbot is reporting
unregister_netdevice: waiting for vcan0 to become free. Usage count = 2
problem, for j1939 protocol did not have NETDEV_UNREGISTER notification handler for undoing changes made by j1939_sk_bind().
Commit 25fe97cb7620 ("can: j1939: move j1939_priv_put() into sk_destruct callback") expects that a call to j1939_priv_put() can be unconditionally delayed until j1939_sk_sock_destruct() is called. But we need to call j1939_priv_put() against an extra ref held by j1939_sk_bind() call (as a part of undoing changes made by j1939_sk_bind()) as soon as NETDEV_UNREGISTER notification fires (i.e. before j1939_sk_sock_destruct() is called via j1939_sk_release()). Otherwise, the extra ref on "struct j1939_priv" held by j1939_sk_bind() call prevents "struct net_device" from dropping the usage count to 1; making it impossible for unregister_netdevice() to continue.
--- net/can/j1939/j1939-priv.h | 1 + net/can/j1939/main.c | 3 +++ net/can/j1939/socket.c | 49 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+)
net/can/j1939/j1939-priv.h +1 -0
@@ -212,6 +212,7 @@ void j1939_priv_get(struct j1939_priv *priv);/* notify/alert all j1939 sockets bound to ifindex */ void j1939_sk_netdev_event_netdown (struct j1939_priv *priv); +void j1939_sk_netdev_event_unregister (struct j1939_priv *priv);int j1939_cancel_active_session (struct j1939_priv *priv,struct sock *sk);void j1939_tp_init (struct j1939_priv *priv);
net/can/j1939/main.c +3 -0
@@ -377,6 +377,9 @@ static int j1939_netdev_notify(struct notifier_block *nb,j1939_sk_netdev_event_netdown (priv);j1939_ecu_unmap_all (priv);break ; +case NETDEV_UNREGISTER : +j1939_sk_netdev_event_unregister (priv); +break ; }j1939_priv_put (priv);
net/can/j1939/socket.c +49 -0
55 lines not on this page · raw message
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 4/7 can: j1939: j1939_sk_bind(): call j1939_priv_put() immediately when j1939_local_ecu_get() failed
In reply to Marc Kleine-BuddeFrom: Tetsuo Handa <[email protected]>
Commit 25fe97cb7620 ("can: j1939: move j1939_priv_put() into sk_destruct callback") expects that a call to j1939_priv_put() can be unconditionally delayed until j1939_sk_sock_destruct() is called. But a refcount leak will happen when j1939_sk_bind() is called again after j1939_local_ecu_get()
from previous j1939_sk_bind() call returned an error. We need to callj1939_priv_put() before j1939_sk_bind() returns an error.
--- net/can/j1939/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/can/j1939/socket.c +3 -0
@@ -521,6 +521,9 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len) ret =j1939_local_ecu_get (priv, jsk->addr.src_name, jsk->addr.sa);if (ret) {j1939_netdev_stop (priv); + jsk->priv =NULL ; +synchronize_rcu (); +j1939_priv_put (priv); goto out_release_sock; }
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 5/7 can: j1939: j1939_local_ecu_get(): undo increment when j1939_local_ecu_get() fails
In reply to Marc Kleine-BuddeFrom: Tetsuo Handa <[email protected]>
Since j1939_sk_bind() and j1939_sk_release() call j1939_local_ecu_put() when J1939_SOCK_BOUND was already set, but the error handling path for j1939_sk_bind() will not set J1939_SOCK_BOUND when j1939_local_ecu_get() fails, j1939_local_ecu_get() needs to undo priv->ents[sa].nusers++ when j1939_local_ecu_get() returns an error.
--- net/can/j1939/bus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/can/j1939/bus.c +4 -1
@@ -290,8 +290,11 @@ int j1939_local_ecu_get(struct j1939_priv *priv, name_t name, u8 sa)if (!ecu) ecu =j1939_ecu_create_locked (priv, name); err =PTR_ERR_OR_ZERO (ecu); -if (err) +if (err) { +if (j1939_address_is_unicast (sa)) + priv->ents[sa].nusers--; goto done; + } ecu->nusers++;/* TODO: do we care if ecu->addr != sa? */
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 6/7 can: xilinx_can: xcan_write_frame(): fix use-after-free of transmitted SKB
In reply to Marc Kleine-BuddeFrom: Anssi Hannula <[email protected]>
can_put_echo_skb() takes ownership of the SKB and it may be freed during or after the call.
However, xilinx_can xcan_write_frame() keeps using SKB after the call.
Fix that by only calling can_put_echo_skb() after the code is done touching the SKB.
The tx_lock is held for the entire xcan_write_frame() execution and also on the can_get_echo_skb() side so the order of operations does not matter.
An earlier fix commit 3d3c817c3a40 ("can: xilinx_can: Fix usage of skb memory") did not move the can_put_echo_skb() call far enough.
--- drivers/net/can/xilinx_can.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/can/xilinx_can.c +8 -8
@@ -690,14 +690,6 @@ static void xcan_write_frame(struct net_device *ndev, struct sk_buff *skb, dlc |=XCAN_DLCR_EDL_MASK ; } -if (!(priv->devtype.flags &XCAN_FLAG_TX_MAILBOXES ) && - (priv->devtype.flags &XCAN_FLAG_TXFEMP )) -can_put_echo_skb (skb, ndev, priv->tx_head % priv->tx_max,0 ); -else -can_put_echo_skb (skb, ndev,0 ,0 ); - - priv->tx_head++; - priv->write_reg (priv,XCAN_FRAME_ID_OFFSET (frame_offset), id);/* If the CAN frame is RTR frame this write triggers transmission * (not on CAN FD)
@@ -730,6 +722,14 @@ static void xcan_write_frame(struct net_device *ndev, struct sk_buff *skb, data[1]); } } + +if (!(priv->devtype.flags &XCAN_FLAG_TX_MAILBOXES ) && + (priv->devtype.flags &XCAN_FLAG_TXFEMP )) +can_put_echo_skb (skb, ndev, priv->tx_head % priv->tx_max,0 ); +else +can_put_echo_skb (skb, ndev,0 ,0 ); + + priv->tx_head++; }/**
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 7/7 can: rcar_can: rcar_can_resume(): fix s2ram with PSCI
In reply to Marc Kleine-BuddeFrom: Geert Uytterhoeven <[email protected]>
On R-Car Gen3 using PSCI, s2ram powers down the SoC. After resume, the CAN interface no longer works, until it is brought down and up again.
Fix this by calling rcar_can_start() from the PM resume callback, to fully initialize the controller instead of just restarting it.
--- drivers/net/can/rcar/rcar_can.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/can/rcar/rcar_can.c +1 -7
@@ -861,7 +861,6 @@ static int rcar_can_resume(struct device *dev) {struct net_device *ndev =dev_get_drvdata (dev);struct rcar_can_priv *priv =netdev_priv (ndev); -u16 ctlr;int err;if (!netif_running (ndev))
@@ -873,12 +872,7 @@ static int rcar_can_resume(struct device *dev)return err; } - ctlr =readw (&priv->regs->ctlr); - ctlr &= ~RCAR_CAN_CTLR_SLPM ; -writew (ctlr, &priv->regs->ctlr); - ctlr &= ~RCAR_CAN_CTLR_CANM ; -writew (ctlr, &priv->regs->ctlr); - priv->can.state =CAN_STATE_ERROR_ACTIVE ; +rcar_can_start (ndev);netif_device_attach (ndev);netif_start_queue (ndev);
Signature · 1 line
2.51.0