Skip to contentSkip to conversation

pull-request: can 2026-11-17

PATCH In review Marc Kleine-Budde 5 participants 28 messages Nov 17 – Nov 24

Subsystems (5)
lore
Share & tools
lore

Marc Kleine-Budde

author maintainer
#0 lore raw

cover pull-request: can 2026-11-17

Hello netdev-team,

this is a pull request of 11 patches for net/main.

The first 7 patches are by Oliver Hartkopp and avoid RTNL stalls in CAN_RAW, CAN_ISOTP and CAN_BCM protocols and fix CAN_ISOTP issues.

Followed by 3 patches are by Zhu Ling that fix problems with the CAN netlink handling.

A patch by my fixes a kernel memory information leak over USB in the gs_usb driver.

regards,
Marc

---

The following changes since commit 5e9b2ad9b8384cd3c417cd5e2c3bc7eee4a72791:

net/mlx5e: rep, Fix races between devcom PAIR event and uplink close (2026-11-17 16:12:52 +0100)

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-7.4-20261117

for you to fetch changes up to b772103b7a4feeee02fa12a3223a7fb5a5a8a81c:

can: gs_usb: gs_can_start_xmit(): don't leak uninitialized memory over USB (2026-11-17 22:26:21 +0100)

----------------------------------------------------------------
linux-can-fixes-for-7.4-20261117

----------------------------------------------------------------
Marc Kleine-Budde (2):
Merge patch series "can: avoid RTNL stalls and fix CAN_ISOTP and netlink issues"
can: gs_usb: gs_can_start_xmit(): don't leak uninitialized memory over USB

Oliver Hartkopp (7):
can: bcm: copy the CAN frames outside of lock_sock()
can: bcm: do not remove the procfs entry in bcm_notify()
can: raw: use a private mutex instead of lock_sock()
can: isotp: use a private mutex instead of lock_sock()
can: bcm: use a private mutex instead of lock_sock()
can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state
can: isotp: reject socket options while a transfer is active

Zhu Ling (3):
can: netlink: fix static FD-NON-ISO mode validation
can: netlink: fix IFLA_CAN_BITRATE_MAX attribute sizing
can: netlink: fix CAN XL PWM attribute sizing

 drivers/net/can/dev/netlink.c |  22 +++++---
 drivers/net/can/usb/gs_usb.c  |   2 +-
 net/can/bcm.c                 | 114 ++++++++++++++++++++++++++++++------------
 net/can/isotp.c               |  50 +++++++++++-------
 net/can/raw.c                 |  41 ++++++++-------
 5 files changed, 153 insertions(+), 76 deletions(-)
author maintainer
#1 lore raw

PATCH 1/11 can: bcm: copy the CAN frames outside of lock_sock()

From: Oliver Hartkopp <[email protected]>

bcm_sendmsg() copies the CAN frames of TX_SETUP, RX_SETUP and TX_SEND from user space while holding lock_sock(). A copy that faults or stalls, e.g. on a FUSE backed mapping, holds lock_sock() for its whole duration.

bcm_notify() takes lock_sock() of every CAN_BCM socket in the namespace of a vanishing CAN device while holding RTNL, independent of the binding of the socket. So a stalled copy on any CAN_BCM socket can block RTNL on the unregistration or namespace change of a CAN device in this namespace, e.g. of a vcan device in an unprivileged user and network namespace.

Copy the CAN frames that the opcode handler reads to kernel memory before lock_sock() and hand them to the handlers with a kvec based msghdr. bcm_tx_setup(), bcm_rx_setup() and bcm_tx_send() keep their checks and read the frames with memcpy_from_msg() as before. Up to sizeof(struct canfd_frame) bytes, i.e. a single CAN FD frame or up to four CAN CC frames, are copied to a buffer on the stack, more frames to a kvmalloc() buffer of up to MAX_NFRAMES + 1 CAN FD frames.

As the frames are copied before lock_sock() now, a failing copy is reported before the error conditions that are checked under lock_sock(). This is in line with POSIX, which does not define an order in which multiple error conditions are detected and reported.

The generic SOL_SOCKET options in sk_setsockopt() and sk_getsockopt(), e.g. SO_ATTACH_FILTER, still access user space under the socket lock. This is not specific to CAN_BCM and not addressed by this patch.

Fixes ffd980f976e7 ("[CAN]: Add broadcast manager (bcm) protocol")
Cc Vincent Mailhol <[email protected]>
Cc Marc Kleine-Budde <[email protected]>
Cc Oleksij Rempel <[email protected]>
Cc Zhu Ling <[email protected]>
---
 net/can/bcm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 52 insertions(+), 3 deletions(-)
net/can/bcm.c +52 -3
index 7bd2aa39777a..3f4c8d828337 100644
@@ -1643,6 +1643,11 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 	struct bcm_sock *bo = bcm_sk(sk);
 	int ifindex;
 	struct bcm_msg_head msg_head;
+	struct msghdr fmsg = {};	/* CAN frames copied to kernel memory */
+	struct kvec kv;
+	struct canfd_frame sframe;	/* stack buffer for up to CANFD_MTU bytes */
+	void *frames = &sframe;
+	size_t flen = 0;
 	int cfsiz;
 	int ret; /* read bytes or error codes as return value */
 
@@ -1663,6 +1668,47 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 	if ((size - MHSIZ) % cfsiz)
 		return -EINVAL;
 
+	/* Copy the CAN frames from user space before lock_sock(), so a
+	 * stalled copy can not block bcm_notify() waiting for lock_sock()
+	 * under RTNL. Only the frames the opcode handler reads are copied.
+	 * The handlers keep their checks and read the frames from fmsg.
+	 */
+	switch (msg_head.opcode) {
+	case TX_SETUP:
+		if (msg_head.nframes >= 1 && msg_head.nframes <= MAX_NFRAMES)
+			flen = msg_head.nframes * cfsiz;
+		break;
+
+	case RX_SETUP:
+		if (!(msg_head.flags & RX_FILTER_ID) &&
+		    msg_head.nframes <= MAX_NFRAMES + 1)
+			flen = msg_head.nframes * cfsiz;
+		break;
+
+	case TX_SEND:
+		if (msg_head.nframes == 1 && size == cfsiz + MHSIZ)
+			flen = cfsiz;
+		break;
+	}
+
+	/* a message with missing frames still fails in the handler */
+	flen = min(flen, msg_data_left(msg));
+
+	if (flen > sizeof(sframe)) {
+		frames = kvmalloc(flen, GFP_KERNEL);
+		if (!frames)
+			return -ENOMEM;
+	}
+
+	if (!copy_from_iter_full(frames, flen, &msg->msg_iter)) {
+		ret = -EFAULT;
+		goto out_free;
+	}
+
+	kv.iov_base = frames;
+	kv.iov_len = flen;
+	iov_iter_kvec(&fmsg.msg_iter, ITER_SOURCE, &kv, 1, flen);
+
 	lock_sock(sk);
 
 	/* Re-validate under the socket lock: a concurrent bcm_notify()
@@ -1721,11 +1767,11 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 	switch (msg_head.opcode) {
 
 	case TX_SETUP:
-		ret = bcm_tx_setup(&msg_head, msg, ifindex, sk);
+		ret = bcm_tx_setup(&msg_head, &fmsg, ifindex, sk);
 		break;
 
 	case RX_SETUP:
-		ret = bcm_rx_setup(&msg_head, msg, ifindex, sk);
+		ret = bcm_rx_setup(&msg_head, &fmsg, ifindex, sk);
 		break;
 
 	case TX_DELETE:
@@ -1759,7 +1805,7 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 		if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ))
 			ret = -EINVAL;
 		else
-			ret = bcm_tx_send(msg, ifindex, sk, cfsiz);
+			ret = bcm_tx_send(&fmsg, ifindex, sk, cfsiz);
 		break;
 
 	default:
@@ -1769,6 +1815,9 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 
 out_release:
 	release_sock(sk);
+out_free:
+	if (frames != &sframe)
+		kvfree(frames);
 
 	return ret;
 }

base-commit: 5e9b2ad9b8384cd3c417cd5e2c3bc7eee4a72791

Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH net 01/11] can: bcm: copy the CAN frames outside of lock_sock()

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.

Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
maintainer
#3 lore raw

Re: [PATCH net 01/11] can: bcm: copy the CAN frames outside of lock_sock()

Quoted 5 lines · On 17.11.26 23:12, [email protected] wrote:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Quoted 8 lines

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

The issue was not reported or observed in production. It was found in a review and later proven by a test that provokes an RTNL stall:

The Sashiko AI review (LLM) of a former CAN_BCM patch found a wait chain, where a task that is blocked in a copy to user space holds lock_sock() while the netdev notifier waits for it under RTNL. At that time the chain was a stalled reader of the CAN_BCM procfs entry, which is fixed by "can: bcm: do not remove the procfs entry in bcm_notify()" in this pull request. Following this, the CAN_RAW and CAN_ISOTP socket options have been moved outside of lock_sock() with commit 43c973a0887d ("can: raw, isotp: copy socket options outside of lock_sock()").

A subsequent LLM assisted review of the locking in net/can identified bcm_sendmsg() as the remaining instance of this wait chain: the CAN frames are copied from user space with memcpy_from_msg() under lock_sock(), while bcm_notify() takes lock_sock() of every CAN_BCM socket in the namespace on NETDEV_UNREGISTER under RTNL.

The issue has now been triggered at runtime, analogue to the test for the procfs reader.

With this patch, "can: bcm: do not remove the procfs entry in bcm_notify()" and "can: bcm: use a private mutex instead of lock_sock()" in this pull request, stalled user space accesses on CAN_BCM sockets can not block RTNL anymore.

Best regards,
Oliver

author maintainer
#4 lore raw

PATCH 2/11 can: bcm: do not remove the procfs entry in bcm_notify()

In reply to Marc Kleine-Budde

From: Oliver Hartkopp <[email protected]>

bcm_notify() removes the procfs entry of a CAN_BCM socket that is bound to a vanishing CAN device with remove_proc_entry() while holding RTNL. remove_proc_entry() waits for all running readers of this entry. A reader of /proc/net/can-bcm/<inode> that stalls in its copy to user space, e.g. on a FUSE backed mapping, therefore blocks RTNL on the unregistration or namespace change of the bound CAN device.

The entry has been removed in bcm_notify() so that a later bcm_connect() of the unbound socket can register it again without a "proc_dir_entry already registered" warning.

The CAN_BCM socket itself stays usable after a NETDEV_UNREGISTER:
bcm_notify() only unbinds it and reports ENODEV, so the application can connect() the socket again, e.g. to a re-created CAN device. The name of the procfs entry is the inode number of the socket, which does not change until the socket is closed.

Keep the procfs entry until bcm_release() instead, which removes it after the socket has left the notifier list and without holding RTNL. bcm_connect() only creates the entry, if it does not exist yet. bcm_proc_show() reports an unbound socket as "unbound" instead of showing the cleared ifindex as "any".

As bcm_proc_show() can now run while the socket is bound or unbound, it reads bo->ifindex locklessly with READ_ONCE() and the writers use WRITE_ONCE(). The NETDEV_DOWN handling in bcm_notify(), which runs without lock_sock(), reads bo->bound and bo->ifindex with READ_ONCE() as well. bo->ifindex is still only modified under lock_sock(). A concurrent bind or unbind may show an intermediate state in the procfs output, which is acceptable for this debug information.

Fixes 76fe372ccb81 ("can: bcm: Remove proc entry when dev is unregistered.")
Cc Vincent Mailhol <[email protected]>
Cc Marc Kleine-Budde <[email protected]>
Cc Oleksij Rempel <[email protected]>
Cc Zhu Ling <[email protected]>
---
 net/can/bcm.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)
net/can/bcm.c +15 -18
index 3f4c8d828337..1595b7720c98 100644
@@ -219,11 +219,16 @@ static int bcm_proc_show(struct seq_file *m, void *v)
 	struct net *net = m->private;
 	struct sock *sk = (struct sock *)pde_data(m->file->f_inode);
 	struct bcm_sock *bo = bcm_sk(sk);
+	int ifindex = READ_ONCE(bo->ifindex);
 	struct bcm_op *op;
 
 	seq_printf(m, ">>> sock inode %s", bo->procname);
 	seq_printf(m, " / dropped %lu", bo->dropped_usr_msgs);
-	seq_printf(m, " / bound %s", bcm_proc_getifname(net, ifname, bo->ifindex));
+	if (READ_ONCE(bo->bound))
+		seq_printf(m, " / bound %s",
+			   bcm_proc_getifname(net, ifname, ifindex));
+	else
+		seq_puts(m, " / unbound");
 	seq_printf(m, " <<<\n");
 
 	rcu_read_lock();
@@ -1866,19 +1871,9 @@ static void bcm_notify(struct bcm_sock *bo, unsigned long msg,
 
 		/* remove device reference, if this is our bound device */
 		if (bo->bound && bo->ifindex == dev->ifindex) {
-#if IS_ENABLED(CONFIG_PROC_FS)
-			if (sock_net(sk)->can.bcmproc_dir && bo->bcm_proc_read) {
-				remove_proc_entry(bo->procname, sock_net(sk)->can.bcmproc_dir);
-				bo->bcm_proc_read = NULL;
-			}
-#endif
-			/* Paired with the lockless fast-path check in
-			 * bcm_sendmsg(); bo->ifindex itself is only ever
-			 * accessed under lock_sock() so it needs no
-			 * annotation.
-			 */
+			/* pairs with the lockless check in bcm_sendmsg() */
 			WRITE_ONCE(bo->bound, 0);
-			bo->ifindex = 0;
+			WRITE_ONCE(bo->ifindex, 0);
 			notify_enodev = 1;
 		}
 
@@ -1892,7 +1887,8 @@ static void bcm_notify(struct bcm_sock *bo, unsigned long msg,
 		break;
 
 	case NETDEV_DOWN:
-		if (bo->bound && bo->ifindex == dev->ifindex) {
+		if (READ_ONCE(bo->bound) &&
+		    READ_ONCE(bo->ifindex) == dev->ifindex) {
 			sk->sk_err = ENETDOWN;
 			if (!sock_flag(sk, SOCK_DEAD))
 				sk_error_report(sk);
@@ -2013,7 +2009,7 @@ static int bcm_release(struct socket *sock)
 	/* remove device reference */
 	if (bo->bound) {
 		WRITE_ONCE(bo->bound, 0);
-		bo->ifindex = 0;
+		WRITE_ONCE(bo->ifindex, 0);
 	}
 
 	sock_orphan(sk);
@@ -2060,16 +2056,17 @@ static int bcm_connect(struct socket *sock, struct sockaddr_unsized *uaddr, int
 			goto fail;
 		}
 
-		bo->ifindex = dev->ifindex;
+		WRITE_ONCE(bo->ifindex, dev->ifindex);
 		dev_put(dev);
 
 	} else {
 		/* no interface reference for ifindex = 0 ('any' CAN device) */
-		bo->ifindex = 0;
+		WRITE_ONCE(bo->ifindex, 0);
 	}
 
 #if IS_ENABLED(CONFIG_PROC_FS)
-	if (net->can.bcmproc_dir) {
+	/* create the procfs entry once, it is removed in bcm_release() */
+	if (net->can.bcmproc_dir && !bo->bcm_proc_read) {
 		/* use unique socket inode number as filename */
 		snprintf(bo->procname, sizeof(bo->procname),
 			 "%llu", sock_i_ino(sk));
Signature · 1 line
2.53.0
author maintainer
#5 lore raw

PATCH 3/11 can: raw: use a private mutex instead of lock_sock()

In reply to Marc Kleine-Budde

From: Oliver Hartkopp <[email protected]>

raw_notify() takes lock_sock() of the sockets that are bound to a vanishing CAN device while holding RTNL. Any path that holds the socket lock while accessing user space can therefore block RTNL. Since commit 43c973a0887d ("can: raw, isotp: copy socket options outside of lock_sock()") the CAN_RAW specific socket options copy their values outside of the socket lock, but the generic SOL_SOCKET options in sk_setsockopt() and sk_getsockopt() still access user space under sockopt_lock_sock(), e.g. for SO_ATTACH_FILTER, SO_LINGER or SO_TXTIME. A stalled copy, e.g. on a FUSE backed mapping, then blocks raw_notify() and RTNL on the unregistration or namespace change of the bound CAN device.

CAN_RAW only uses lock_sock() to serialize its own state: the binding, the filters and the CAN_RAW socket options. It does not use the socket backlog, as raw_rcv() queues the frames directly to the socket.

Replace lock_sock() with the mutex conf_lock in struct raw_sock. The generic socket options do not take this mutex, so they can not block raw_notify() anymore. No user space access happens while the mutex is held. The memory allocations for the CAN receivers in can_rx_register() are still done under the mutex, as they have been under lock_sock() before.

Sashiko suggested to hold not only the filter copy in raw_getsockopt() under the new conf_lock mutex but to also protect ro->raw_vcid_opts. This change will be addressed in a follow-up patch as it goes beyond a simple lock replacement intended for stable.

Fixes c18ce101f2e4 ("[CAN]: Add raw protocol")
Cc [email protected] # depends on "can: raw, isotp: copy socket options outside of lock_sock()"
Cc Vincent Mailhol <[email protected]>
Cc Marc Kleine-Budde <[email protected]>
Cc Oleksij Rempel <[email protected]>
Cc Zhu Ling <[email protected]>
---
 net/can/raw.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)
net/can/raw.c +22 -19
index f14270b56f52..b69eaadc5e93 100644
@@ -103,6 +103,7 @@ struct raw_sock {
 	struct can_filter dfilter; /* default/single filter */
 	struct can_filter *filter; /* pointer to filter(s) */
 	struct uniqframe __percpu *uniq;
+	struct mutex conf_lock; /* protects bind, filters and setsockopt */
 };
 
 static LIST_HEAD(raw_notifier_list);
@@ -319,7 +320,7 @@ static void raw_notify(struct raw_sock *ro, unsigned long msg,
 
 	/* Lockless fast path, ro->bind_dev covers a concurrent bind().
 	 * Read it before ro->dev, pairs with smp_store_release() in
-	 * raw_bind(). A stale ro->bind_dev only costs a lock_sock().
+	 * raw_bind(). A stale ro->bind_dev only costs a mutex_lock().
 	 */
 	bind_dev = smp_load_acquire(&ro->bind_dev);
 	if (READ_ONCE(ro->dev) != dev &&
@@ -328,9 +329,9 @@ static void raw_notify(struct raw_sock *ro, unsigned long msg,
 
 	switch (msg) {
 	case NETDEV_UNREGISTER:
-		lock_sock(sk);
+		mutex_lock(&ro->conf_lock);
 		if (ro->dev != dev) {
-			release_sock(sk);
+			mutex_unlock(&ro->conf_lock);
 			break;
 		}
 
@@ -351,7 +352,7 @@ static void raw_notify(struct raw_sock *ro, unsigned long msg,
 		sk->sk_err = ENODEV;
 		if (!sock_flag(sk, SOCK_DEAD))
 			sk_error_report(sk);
-		release_sock(sk);
+		mutex_unlock(&ro->conf_lock);
 		break;
 
 	case NETDEV_DOWN:
@@ -401,6 +402,7 @@ static int raw_init(struct sock *sk)
 	ro->ifindex          = 0;
 	ro->dev              = NULL;
 	ro->bind_dev         = NULL;
+	mutex_init(&ro->conf_lock);
 
 	/* set default filter to single entry dfilter */
 	ro->dfilter.can_id   = 0;
@@ -451,7 +453,7 @@ static int raw_release(struct socket *sock)
 	list_del(&ro->notifier);
 	spin_unlock(&raw_notifier_lock);
 
-	lock_sock(sk);
+	mutex_lock(&ro->conf_lock);
 
 	/* remove current filters & unregister
 	 * the tracked reference ro->dev keeps the device's receive lists
@@ -474,11 +476,11 @@ static int raw_release(struct socket *sock)
 	ro->dev = NULL;
 	ro->count = 0;
 
+	mutex_unlock(&ro->conf_lock);
+
 	sock_orphan(sk);
 	sock->sk = NULL;
 
-	release_sock(sk);
-
 	sock_prot_inuse_add(net, sk->sk_prot, -1);
 	sock_put(sk);
 
@@ -500,8 +502,8 @@ static int raw_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int len
 	if (addr->can_family != AF_CAN)
 		return -EINVAL;
 
-	/* lock_sock() serializes the binding with raw_notify() */
-	lock_sock(sk);
+	/* ro->conf_lock serializes the binding with raw_notify() */
+	mutex_lock(&ro->conf_lock);
 
 	if (ro->bound && addr->can_ifindex == ro->ifindex)
 		goto out;
@@ -581,7 +583,7 @@ static int raw_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int len
 			sk_error_report(sk);
 	}
 
-	release_sock(sk);
+	mutex_unlock(&ro->conf_lock);
 
 	return err;
 }
@@ -621,7 +623,7 @@ static int raw_setsockopt_locked(struct socket *sock, int optname,
 		 *
 		 * The reg_state check is only a shortcut: On a concurrent
 		 * unregistration or namespace change raw_notify() waits for
-		 * lock_sock() and removes the filters set here.
+		 * ro->conf_lock and removes the filters set here.
 		 */
 		dev = ro->dev;
 		if (ro->bound && dev &&
@@ -730,6 +732,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 			  sockptr_t optval, unsigned int optlen)
 {
 	struct sock *sk = sock->sk;
+	struct raw_sock *ro = raw_sk(sk);
 	struct can_filter *filter = NULL;  /* dyn. alloc'ed filters */
 	struct can_filter sfilter;         /* single filter */
 	union {
@@ -744,9 +747,9 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 	if (level != SOL_CAN_RAW)
 		return -EINVAL;
 
-	/* Copy the option values from user space before lock_sock(), so a
-	 * stalled copy can not block raw_notify() waiting for lock_sock()
-	 * under RTNL.
+	/* Copy the option values from user space before taking ro->conf_lock,
+	 * so a stalled copy can not block raw_notify() waiting for
+	 * ro->conf_lock under RTNL.
 	 */
 	switch (optname) {
 	case CAN_RAW_FILTER:
@@ -798,11 +801,11 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 			return -EFAULT;
 	}
 
-	lock_sock(sk);
+	mutex_lock(&ro->conf_lock);
 
 	err = raw_setsockopt_locked(sock, optname, &val, filter, count);
 
-	release_sock(sk);
+	mutex_unlock(&ro->conf_lock);
 
 	/* on error free the filters allocated for CAN_RAW_FILTER above */
 	if (err && count > 1)
@@ -831,7 +834,7 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
 		struct can_filter *filter = NULL;
 		int err = 0;
 
-		lock_sock(sk);
+		mutex_lock(&ro->conf_lock);
 		if (ro->count > 0) {
 			int fsize = ro->count * sizeof(struct can_filter);
 
@@ -843,7 +846,7 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
 			} else {
 				if (len > fsize)
 					len = fsize;
-				/* copy to user space after release_sock() */
+				/* copy to user space after mutex_unlock() */
 				filter = kmemdup(ro->filter, len, GFP_KERNEL);
 				if (!filter)
 					err = -ENOMEM;
@@ -851,7 +854,7 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
 		} else {
 			len = 0;
 		}
-		release_sock(sk);
+		mutex_unlock(&ro->conf_lock);
 
 		if (filter) {
 			if (copy_to_iter(filter, len, &opt->iter_out) != len)
Signature · 1 line
2.53.0
author maintainer
#6 lore raw

PATCH 4/11 can: isotp: use a private mutex instead of lock_sock()

In reply to Marc Kleine-Budde

From: Oliver Hartkopp <[email protected]>

isotp_notify() takes lock_sock() of a socket that is bound to a vanishing CAN device while holding RTNL. Any path that holds the socket lock while accessing user space can therefore block RTNL. Since commit 43c973a0887d ("can: raw, isotp: copy socket options outside of lock_sock()") the CAN_ISOTP specific socket options copy their values outside of the socket lock, but the generic SOL_SOCKET options in sk_setsockopt() and sk_getsockopt() still access user space under sockopt_lock_sock(), e.g. for SO_ATTACH_FILTER, SO_LINGER or SO_TXTIME.

CAN_ISOTP only uses lock_sock() to serialize the binding and the CAN_ISOTP socket options. It does not use the socket backlog, as the received PDUs are queued directly to the socket.

Replace lock_sock() with the mutex conf_lock in struct isotp_sock. The generic socket options do not take this mutex, so they can not block isotp_notify() anymore. No user space access happens while the mutex is held. The memory allocations for the CAN receivers in isotp_bind() are still done under the mutex, as they have been under lock_sock() before. isotp_release() drops the mutex before synchronize_rcu() and the hrtimer cancellation, as the socket has already left the notifier list at this point.

Following a Sashiko feedback for raw.c it would make sense to copy the content in isotp_getsockopt() under the new conf_lock mutex too. This change will be addressed in a follow-up patch as it goes beyond a simple lock replacement intended for stable.

Fixes e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol")
Cc [email protected] # depends on "can: raw, isotp: copy socket options outside of lock_sock()"
Cc Vincent Mailhol <[email protected]>
Cc Marc Kleine-Budde <[email protected]>
Cc Oleksij Rempel <[email protected]>
Cc Zhu Ling <[email protected]>
---
 net/can/isotp.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
net/can/isotp.c +16 -12
index 7a90ba3f1cf1..8229b6a69ecd 100644
@@ -182,6 +182,7 @@ struct isotp_sock {
 	struct list_head notifier;
 	wait_queue_head_t wait;
 	spinlock_t rx_lock; /* protect single thread state machine */
+	struct mutex conf_lock; /* protects bind and setsockopt */
 };
 
 static LIST_HEAD(isotp_notifier_list);
@@ -1497,7 +1498,7 @@ static int isotp_release(struct socket *sock)
 	list_del(&so->notifier);
 	spin_unlock(&isotp_notifier_lock);
 
-	lock_sock(sk);
+	mutex_lock(&so->conf_lock);
 
 	/* remove current filters & unregister
 	 * the tracked reference so->dev keeps the device's receive lists
@@ -1519,6 +1520,8 @@ static int isotp_release(struct socket *sock)
 	WRITE_ONCE(so->bound, 0);
 	so->dev = NULL;
 
+	mutex_unlock(&so->conf_lock);
+
 	/* Always wait for a grace period before touching the timers below.
 	 * A concurrent NETDEV_UNREGISTER may have already unregistered our
 	 * filters and cleared so->bound in isotp_notify() without waiting
@@ -1535,7 +1538,6 @@ static int isotp_release(struct socket *sock)
 	sock_orphan(sk);
 	sock->sk = NULL;
 
-	release_sock(sk);
 	sock_prot_inuse_add(net, sk->sk_prot, -1);
 	sock_put(sk);
 
@@ -1585,8 +1587,8 @@ static int isotp_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int l
 	if (!addr->can_ifindex)
 		return -ENODEV;
 
-	/* lock_sock() serializes the binding with isotp_notify() */
-	lock_sock(sk);
+	/* so->conf_lock serializes the binding with isotp_notify() */
+	mutex_lock(&so->conf_lock);
 
 	if (so->bound) {
 		err = -EINVAL;
@@ -1596,7 +1598,7 @@ static int isotp_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int l
 	/* A transmission or reception that outlived a previous binding
 	 * (unbound by NETDEV_UNREGISTER) may still be draining; the FC/echo
 	 * and RX watchdog timers bound how long this takes. Checked together
-	 * with so->bound in the same lock_sock() section above, so there is
+	 * with so->bound in the same so->conf_lock section above, so there is
 	 * no window in which a concurrent isotp_notify() could be missed.
 	 */
 	if (READ_ONCE(so->tx.state) != ISOTP_IDLE ||
@@ -1686,7 +1688,7 @@ static int isotp_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int l
 			sk_error_report(sk);
 	}
 
-	release_sock(sk);
+	mutex_unlock(&so->conf_lock);
 
 	return err;
 }
@@ -1790,6 +1792,7 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname,
 
 {
 	struct sock *sk = sock->sk;
+	struct isotp_sock *so = isotp_sk(sk);
 	union {
 		struct can_isotp_options opt;
 		struct can_isotp_fc_options rxfc;
@@ -1802,7 +1805,7 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname,
 	if (level != SOL_CAN_ISOTP)
 		return -EINVAL;
 
-	/* copy the option values from user space before lock_sock() */
+	/* copy the option values from user space before taking so->conf_lock */
 	switch (optname) {
 	case CAN_ISOTP_OPTS:
 		size = sizeof(val.opt);
@@ -1831,9 +1834,9 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname,
 	if (copy_from_sockptr(&val, optval, size))
 		return -EFAULT;
 
-	lock_sock(sk);
+	mutex_lock(&so->conf_lock);
 	ret = isotp_setsockopt_locked(sock, optname, &val);
-	release_sock(sk);
+	mutex_unlock(&so->conf_lock);
 	return ret;
 }
 
@@ -1906,9 +1909,9 @@ static void isotp_notify(struct isotp_sock *so, unsigned long msg,
 
 	switch (msg) {
 	case NETDEV_UNREGISTER:
-		lock_sock(sk);
+		mutex_lock(&so->conf_lock);
 		if (so->dev != dev) {
-			release_sock(sk);
+			mutex_unlock(&so->conf_lock);
 			break;
 		}
 
@@ -1932,7 +1935,7 @@ static void isotp_notify(struct isotp_sock *so, unsigned long msg,
 		sk->sk_err = ENODEV;
 		if (!sock_flag(sk, SOCK_DEAD))
 			sk_error_report(sk);
-		release_sock(sk);
+		mutex_unlock(&so->conf_lock);
 		break;
 
 	case NETDEV_DOWN:
@@ -1991,6 +1994,7 @@ static int isotp_init(struct sock *sk)
 	so->ifindex = 0;
 	so->bound = 0;
 	so->dev = NULL;
+	mutex_init(&so->conf_lock);
 
 	so->opt.flags = CAN_ISOTP_DEFAULT_FLAGS;
 	so->opt.ext_address = CAN_ISOTP_DEFAULT_EXT_ADDRESS;
Signature · 1 line
2.53.0
author maintainer
#7 lore raw

PATCH 5/11 can: bcm: use a private mutex instead of lock_sock()

In reply to Marc Kleine-Budde

From: Oliver Hartkopp <[email protected]>

bcm_notify() takes lock_sock() of every CAN_BCM socket in the namespace of a vanishing CAN device while holding RTNL. Any path that holds the socket lock while accessing user space can therefore block RTNL. With "can: bcm: copy the CAN frames outside of lock_sock()" the CAN frames of bcm_sendmsg() are copied outside of the socket lock, but the generic SOL_SOCKET options in sk_setsockopt() and sk_getsockopt() still access user space under sockopt_lock_sock(), e.g. for SO_ATTACH_FILTER, SO_LINGER or SO_TXTIME.

CAN_BCM only uses lock_sock() to serialize the binding and the bcm_op lists. It does not use the socket backlog, as the BCM messages are queued directly to the socket.

Replace lock_sock() with the mutex conf_lock in struct bcm_sock. The generic socket options do not take this mutex, so they can not block bcm_notify() anymore. No user space access happens while the mutex is held. The memory allocations for the bcm_ops and the CAN receivers are still done under the mutex, as they have been under lock_sock() before.

bcm_release() removes the procfs entry before taking the mutex, as remove_proc_entry() waits for readers that may stall in their copy to user space. The socket has already left the notifier list at this point.

Fixes ffd980f976e7 ("[CAN]: Add broadcast manager (bcm) protocol")
Cc [email protected] # depends on "can: bcm: copy the CAN frames outside of lock_sock()"
Cc Vincent Mailhol <[email protected]>
Cc Marc Kleine-Budde <[email protected]>
Cc Oleksij Rempel <[email protected]>
Cc Zhu Ling <[email protected]>
---
 net/can/bcm.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)
net/can/bcm.c +16 -14
index 1595b7720c98..dc9e2890490a 100644
@@ -145,6 +145,7 @@ struct bcm_sock {
 	unsigned long dropped_usr_msgs;
 	struct proc_dir_entry *bcm_proc_read;
 	char procname [32]; /* inode number in decimal with \0 */
+	struct mutex conf_lock; /* protects bind and the bcm_op lists */
 };
 
 static LIST_HEAD(bcm_notifier_list);
@@ -1673,8 +1674,8 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 	if ((size - MHSIZ) % cfsiz)
 		return -EINVAL;
 
-	/* Copy the CAN frames from user space before lock_sock(), so a
-	 * stalled copy can not block bcm_notify() waiting for lock_sock()
+	/* Copy the CAN frames from user space before taking bo->conf_lock, so a
+	 * stalled copy can not block bcm_notify() waiting for bo->conf_lock
 	 * under RTNL. Only the frames the opcode handler reads are copied.
 	 * The handlers keep their checks and read the frames from fmsg.
 	 */
@@ -1714,12 +1715,12 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 	kv.iov_len = flen;
 	iov_iter_kvec(&fmsg.msg_iter, ITER_SOURCE, &kv, 1, flen);
 
-	lock_sock(sk);
+	mutex_lock(&bo->conf_lock);
 
-	/* Re-validate under the socket lock: a concurrent bcm_notify()
+	/* Re-validate under bo->conf_lock: a concurrent bcm_notify()
 	 * may have unbound this socket (device removal) after the
 	 * lockless fast-path check above. bo->ifindex is only ever
-	 * mutated under lock_sock(), so reading it here - instead of
+	 * mutated under bo->conf_lock, so reading it here - instead of
 	 * before taking the lock - guarantees it can't be observed
 	 * torn against bo->bound.
 	 */
@@ -1819,7 +1820,7 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 	}
 
 out_release:
-	release_sock(sk);
+	mutex_unlock(&bo->conf_lock);
 out_free:
 	if (frames != &sframe)
 		kvfree(frames);
@@ -1843,7 +1844,7 @@ static void bcm_notify(struct bcm_sock *bo, unsigned long msg,
 	switch (msg) {
 
 	case NETDEV_UNREGISTER:
-		lock_sock(sk);
+		mutex_lock(&bo->conf_lock);
 
 		/* rx_ops: remove device specific receive entries */
 		list_for_each_entry(op, &bo->rx_ops, list) {
@@ -1877,7 +1878,7 @@ static void bcm_notify(struct bcm_sock *bo, unsigned long msg,
 			notify_enodev = 1;
 		}
 
-		release_sock(sk);
+		mutex_unlock(&bo->conf_lock);
 
 		if (notify_enodev) {
 			sk->sk_err = ENODEV;
@@ -1930,6 +1931,7 @@ static int bcm_init(struct sock *sk)
 	bo->ifindex          = 0;
 	bo->dropped_usr_msgs = 0;
 	bo->bcm_proc_read    = NULL;
+	mutex_init(&bo->conf_lock);
 
 	INIT_LIST_HEAD(&bo->tx_ops);
 	INIT_LIST_HEAD(&bo->rx_ops);
@@ -1969,15 +1971,14 @@ static int bcm_release(struct socket *sock)
 	list_del(&bo->notifier);
 	spin_unlock(&bcm_notifier_lock);
 
-	/* bcm_notify() can not access this socket anymore */
-	lock_sock(sk);
-
 #if IS_ENABLED(CONFIG_PROC_FS)
 	/* remove procfs entry */
 	if (net->can.bcmproc_dir && bo->bcm_proc_read)
 		remove_proc_entry(bo->procname, net->can.bcmproc_dir);
 #endif /* CONFIG_PROC_FS */
 
+	mutex_lock(&bo->conf_lock);
+
 	list_for_each_entry_safe(op, next, &bo->tx_ops, list) {
 		list_del_rcu(&op->list);
 		bcm_remove_op(op);
@@ -2012,10 +2013,11 @@ static int bcm_release(struct socket *sock)
 		WRITE_ONCE(bo->ifindex, 0);
 	}
 
+	mutex_unlock(&bo->conf_lock);
+
 	sock_orphan(sk);
 	sock->sk = NULL;
 
-	release_sock(sk);
 	sock_prot_inuse_add(net, sk->sk_prot, -1);
 	sock_put(sk);
 
@@ -2034,7 +2036,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr_unsized *uaddr, int
 	if (len < BCM_MIN_NAMELEN)
 		return -EINVAL;
 
-	lock_sock(sk);
+	mutex_lock(&bo->conf_lock);
 
 	if (bo->bound) {
 		ret = -EISCONN;
@@ -2086,7 +2088,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr_unsized *uaddr, int
 	WRITE_ONCE(bo->bound, 1);
 
 fail:
-	release_sock(sk);
+	mutex_unlock(&bo->conf_lock);
 
 	return ret;
 }
Signature · 1 line
2.53.0
author maintainer
#8 lore raw

PATCH 6/11 can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

In reply to Marc Kleine-Budde

From: Oliver Hartkopp <[email protected]>

The rx timeout is only started at the end of isotp_send_fc() and for consecutive frames inside a block in isotp_rcv_cf(). So so->rx.state can stay in ISOTP_WAIT_DATA without a running rx timeout:

- isotp_send_fc() returns early, when it can not allocate the skb or does not find the CAN device anymore
- isotp_rcv_ff() does not send a flow control frame in listen mode
- isotp_rcv_cf() has stopped the rx timeout and does not restart it at the end of a block, when the flow control frame is not sent

On a bound socket the next first frame or single frame resets the state. But when the CAN device has been removed, no further CAN frame is received and so->rx.state remains in ISOTP_WAIT_DATA. isotp_bind() then rejects a new binding with -EAGAIN until the socket is closed.

Start the rx timeout in isotp_rcv_ff() and isotp_rcv_cf() whenever the reception continues in ISOTP_WAIT_DATA state, before a flow control frame is sent. isotp_send_fc() restarts the rx timeout as before. All this runs under so->rx_lock, so the order of the rx timeout start and the transmission of the flow control frame does not matter.

In listen mode a first frame that is not followed by consecutive frames now leads to ETIMEDOUT, like a missing consecutive frame inside a block already does. So a listening socket reports a missing consecutive frame consistently, independent of its position in the PDU.

Fixes e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol")
Cc Vincent Mailhol <[email protected]>
Cc Marc Kleine-Budde <[email protected]>
Cc Oleksij Rempel <[email protected]>
Cc Zhu Ling <[email protected]>
---
 net/can/isotp.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
net/can/isotp.c +9 -5
index 8229b6a69ecd..0293d590186c 100644
@@ -634,6 +634,10 @@ static int isotp_rcv_ff(struct sock *sk, struct canfd_frame *cf, int ae)
 	so->rx.sn = 1;
 	WRITE_ONCE(so->rx.state, ISOTP_WAIT_DATA);
 
+	/* start rx timeout, isotp_send_fc() restarts it */
+	hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
+		      HRTIMER_MODE_REL_SOFT);
+
 	/* no creation of flow control frames */
 	if (so->opt.flags & CAN_ISOTP_LISTEN_MODE)
 		return 0;
@@ -726,13 +730,13 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
 		return 0;
 	}
 
+	/* start rx timeout, isotp_send_fc() restarts it */
+	hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
+		      HRTIMER_MODE_REL_SOFT);
+
 	/* perform blocksize handling, if enabled */
-	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs) {
-		/* start rx timeout watchdog */
-		hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
-			      HRTIMER_MODE_REL_SOFT);
+	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs)
 		return 0;
-	}
 
 	/* no creation of flow control frames */
 	if (so->opt.flags & CAN_ISOTP_LISTEN_MODE)
Signature · 1 line
2.53.0
#9 lore raw

Re: [PATCH net 06/11] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] can: isotp: rxtimer not restarted on invalid CF length in isotp_rcv_cf() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] can: isotp: rxtimer not restarted on invalid CF length in isotp_rcv_cf()
--

commit 94f5ff3c55fd4fb8ddb6ad8f21dc67ceb4b06102
Author: Oliver Hartkopp <[email protected]>

can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

This commit starts so->rxtimer in isotp_rcv_ff() and isotp_rcv_cf() before checking CAN_ISOTP_LISTEN_MODE or calling isotp_send_fc() so that reception does not stay in ISOTP_WAIT_DATA without an active timeout.

Quoted 4 lines
net/can/isotp.c +0 -0
index 8229b6a69ecd0..0293d590186c4 100644

[ ... ]

Quoted 9 lines
net/can/isotp.c +4 -0
@@ -726,13 +730,13 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
 		return 0;
 	}
 
+	/* start rx timeout, isotp_send_fc() restarts it */
+	hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
+		      HRTIMER_MODE_REL_SOFT);
+
 	/* perform blocksize handling, if enabled */

net/can/isotp.c static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae, · line 742

Quoted 10 lines
net/can/isotp.c +1 -5
-	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs) {
-		/* start rx timeout watchdog */
-		hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
-			      HRTIMER_MODE_REL_SOFT);
+	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs)
 		return 0;
-	}
 
 	/* no creation of flow control frames */
 	if (so->opt.flags & CAN_ISOTP_LISTEN_MODE)

[Severity: Medium]
Can isotp_rcv_cf() still leave so->rx.state in ISOTP_WAIT_DATA without a running so->rxtimer when cf->len is invalid?

Earlier in isotp_rcv_cf(), so->rxtimer is cancelled before checking cf->len against so->rx.ll_dl:

net/can/isotp.c:isotp_rcv_cf() {
    ...
	hrtimer_cancel(&so->rxtimer);

	if (READ_ONCE(so->rx.state) != ISOTP_WAIT_DATA)
		return 1;

	/* CFs are never longer than the FF */
	if (cf->len > so->rx.ll_dl)
		return 1;

	/* CFs have usually the LL_DL length */
	if (cf->len < so->rx.ll_dl) {
		/* this is only allowed for the last CF */
		if (so->rx.len - so->rx.idx > so->rx.ll_dl - ae - N_PCI_SZ)
			return 1;
	}
    ...
}

Unlike the sequence-number mismatch path below it, which resets so->rx.state to ISOTP_IDLE, a consecutive frame that fails either cf->len check returns before reaching the new hrtimer_start() while leaving so->rx.state in ISOTP_WAIT_DATA. If no further frames arrive (for example, if the CAN device is removed), the transfer never times out and isotp_bind() continues to fail with -EAGAIN until the socket is closed.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#10 lore raw

Re: [PATCH net 06/11] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

In reply to Marc Kleine-Budde
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [High] The fix is incomplete.

--

can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

This patch starts the rx timeout in isotp_rcv_ff() and isotp_rcv_cf() whenever reception continues in ISOTP_WAIT_DATA state. Previously the timeout could be missing when isotp_send_fc() failed, in listen mode, or at the end of a block. Without it, a socket whose CAN device was removed could stay in ISOTP_WAIT_DATA, and isotp_bind() would keep returning -EAGAIN.

Quoted 4 lines
net/can/isotp.c +0 -0
index 8229b6a69ecd0..0293d590186c4 100644

[ ... ]

net/can/isotp.c static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae, · line 736

Quoted 8 lines
net/can/isotp.c +4 -0
@@ -726,13 +730,13 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
 		return 0;
 	}
 
+	/* start rx timeout, isotp_send_fc() restarts it */
+	hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
+		      HRTIMER_MODE_REL_SOFT);
+

[Severity: High]
Does isotp_rcv_cf() still have paths that leave so->rx.state in ISOTP_WAIT_DATA with no rx timer armed?

Earlier in isotp_rcv_cf(), the timer is cancelled unconditionally. Two length checks after that cancel return before this new hrtimer_start() is reached:

net/can/isotp.c:isotp_rcv_cf() {
    ...
	hrtimer_cancel(&so->rxtimer);
    ...
	/* CFs are never longer than the FF */
	if (cf->len > so->rx.ll_dl)
		return 1;

	/* CFs have usually the LL_DL length */
	if (cf->len < so->rx.ll_dl) {
		/* this is only allowed for the last CF */
		if (so->rx.len - so->rx.idx > so->rx.ll_dl - ae - N_PCI_SZ)
			return 1;
	}
    ...
}

Neither path restarts the timer or sets rx.state to ISOTP_IDLE.

Both paths look reachable from the bus, because isotp_rcv() only checks skb->len against so->ll.mtu and never checks cf->len:

- On a CAN CC socket, padlen() gives rx.ll_dl = 8 for the first frame. A following CF with len < 8, sent while more than 7 bytes are still outstanding, takes the second return.

- On a CAN FD socket, a first frame with len 8 (ll_dl = 8) followed by a CF with len 12..64 takes the first return.

The frames could come from any remote node, or from a local CAN_RAW socket on vcan.

Suppose such a malformed CF is the last frame before NETDEV_UNREGISTER. isotp_notify() does not reset rx.state, and isotp_rx_timer_handler() is not armed. So isotp_bind() would still return -EAGAIN until the socket is closed:

net/can/isotp.c:isotp_bind() {
    ...
	if (READ_ONCE(so->tx.state) != ISOTP_IDLE ||
	    READ_ONCE(so->rx.state) != ISOTP_IDLE) {
		err = -EAGAIN;
		goto out;
	}
    ...
}

This is the failure the commit message says it removes.

The later patch in this series, "can: isotp: reject socket options while a transfer is active", adds the same rx.state != ISOTP_IDLE -> -EAGAIN check to isotp_setsockopt_locked(). So setsockopt() would be blocked in the same stuck state.

There is also a case before the device is removed. In CAN_ISOTP_HALF_DUPLEX mode, isotp_rcv() drops every incoming FC frame while rx.state is not ISOTP_IDLE. That lasts until the next FF or SF arrives.

Could these two returns also re-arm the rx timer (or set ISOTP_IDLE)? An alternative would be to restructure the function so that every return after hrtimer_cancel() that keeps ISOTP_WAIT_DATA re-arms the timer.

Quoted 8 lines
net/can/isotp.c +1 -5
 	/* perform blocksize handling, if enabled */
-	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs) {
-		/* start rx timeout watchdog */
-		hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
-			      HRTIMER_MODE_REL_SOFT);
+	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs)
 		return 0;
-	}

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117220818.1142581-2-mkl%40pengutronix.de
maintainer
#11 lore raw

Re: [PATCH net 06/11] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

Quoted 37 lines · On 18.11.26 23:19, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [High] The fix is incomplete.

--

can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

This patch starts the rx timeout in isotp_rcv_ff() and isotp_rcv_cf() whenever reception continues in ISOTP_WAIT_DATA state. Previously the timeout could be missing when isotp_send_fc() failed, in listen mode, or at the end of a block. Without it, a socket whose CAN device was removed could stay in ISOTP_WAIT_DATA, and isotp_bind() would keep returning -EAGAIN.

Quoted 4 lines
net/can/isotp.c +0 -0
index 8229b6a69ecd0..0293d590186c4 100644

[ ... ]

Quoted 4 lines
net/can/isotp.c +0 -0
@@ -726,13 +730,13 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
  		return 0;
  	}
 
Quoted 8 lines

net/can/isotp.c static int isotp_rcv_ff(struct sock *sk, struct canfd_frame *cf, int ae) · line 640

Quoted 4 lines
net/can/isotp.c +4 -0
+	/* start rx timeout, isotp_send_fc() restarts it */
+	hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
+		      HRTIMER_MODE_REL_SOFT);
+

[Severity: High]
Does isotp_rcv_cf() still have paths that leave so->rx.state in ISOTP_WAIT_DATA with no rx timer armed?

Yes. This is a valid finding.

The two length checks for invalid consecutive frames in isotp_rcv_cf() return after hrtimer_cancel(), so so->rx.state stays in ISOTP_WAIT_DATA without a running rx timeout. This already happens without this patch. It is not limited to an attack, as the invalid consecutive frame can be sent by any node on the bus and the CAN device can be removed by an unplug of a USB adapter.

This patch starts the rx timeout in the cases where no flow control frame is sent, i.e. when isotp_send_fc() fails or in listen mode, and is correct for these cases. To also cover invalid consecutive frames I will send a separate patch, which moves the length checks in front of hrtimer_cancel(), as suggested. Then an invalid consecutive frame does not touch the rx timeout and every return after hrtimer_cancel() either ends the reception or restarts the rx timeout.

Best regards,
Oliver

Quoted 79 lines

Earlier in isotp_rcv_cf(), the timer is cancelled unconditionally. Two length checks after that cancel return before this new hrtimer_start() is reached:

net/can/isotp.c:isotp_rcv_cf() {
     ...
	hrtimer_cancel(&so->rxtimer);
     ...
	/* CFs are never longer than the FF */
	if (cf->len > so->rx.ll_dl)
		return 1;

	/* CFs have usually the LL_DL length */
	if (cf->len < so->rx.ll_dl) {
		/* this is only allowed for the last CF */
		if (so->rx.len - so->rx.idx > so->rx.ll_dl - ae - N_PCI_SZ)
			return 1;
	}
     ...
}

Neither path restarts the timer or sets rx.state to ISOTP_IDLE.

Both paths look reachable from the bus, because isotp_rcv() only checks skb->len against so->ll.mtu and never checks cf->len:

- On a CAN CC socket, padlen() gives rx.ll_dl = 8 for the first frame. A following CF with len < 8, sent while more than 7 bytes are still outstanding, takes the second return.

- On a CAN FD socket, a first frame with len 8 (ll_dl = 8) followed by a CF with len 12..64 takes the first return.

The frames could come from any remote node, or from a local CAN_RAW socket on vcan.

Suppose such a malformed CF is the last frame before NETDEV_UNREGISTER. isotp_notify() does not reset rx.state, and isotp_rx_timer_handler() is not armed. So isotp_bind() would still return -EAGAIN until the socket is closed:

net/can/isotp.c:isotp_bind() {
     ...
	if (READ_ONCE(so->tx.state) != ISOTP_IDLE ||
	    READ_ONCE(so->rx.state) != ISOTP_IDLE) {
		err = -EAGAIN;
		goto out;
	}
     ...
}

This is the failure the commit message says it removes.

The later patch in this series, "can: isotp: reject socket options while a transfer is active", adds the same rx.state != ISOTP_IDLE -> -EAGAIN check to isotp_setsockopt_locked(). So setsockopt() would be blocked in the same stuck state.

There is also a case before the device is removed. In CAN_ISOTP_HALF_DUPLEX mode, isotp_rcv() drops every incoming FC frame while rx.state is not ISOTP_IDLE. That lasts until the next FF or SF arrives.

Could these two returns also re-arm the rx timer (or set ISOTP_IDLE)? An alternative would be to restructure the function so that every return after hrtimer_cancel() that keeps ISOTP_WAIT_DATA re-arms the timer.

Quoted 8 lines
net/can/isotp.c +1 -5
  	/* perform blocksize handling, if enabled */
-	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs) {
-		/* start rx timeout watchdog */
-		hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
-			      HRTIMER_MODE_REL_SOFT);
+	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs)
  		return 0;
-	}

[ ... ]

maintainer
#12 lore raw

Re: [PATCH net 06/11] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

Quoted 5 lines · Oliver Hartkopp

On 18.11.26 23:19, [email protected] wrote:

To also cover invalid consecutive frames
I will send a separate patch, which moves the length checks in front of hrtimer_cancel(), as suggested.

As we missed the net-PR for -rc4 I'll re-spin this patch to address the open Sashiko remarks.

pw-bot: cr

author maintainer
#13 lore raw

PATCH 7/11 can: isotp: reject socket options while a transfer is active

In reply to Marc Kleine-Budde

From: Oliver Hartkopp <[email protected]>

isotp_setsockopt_locked() only checks so->bound before it changes the CAN_ISOTP socket options. When the bound CAN device is unregistered, isotp_notify() clears so->bound, but a transmission or reception that is already in progress is not stopped and may still be draining.

isotp_sendmsg() claims so->tx.state and rechecks so->bound. After that it can block in sock_alloc_send_skb(), while the device is unregistered and so->bound is cleared. A concurrent setsockopt() can then change so->opt, so->ll and so->tx.ll_dl, before isotp_sendmsg() reads so->ll.mtu and so->tx.ll_dl again to build the CAN frame for the skb that has been allocated with the former so->ll.mtu.

isotp_bind() already rejects a new binding while so->tx.state or so->rx.state are not ISOTP_IDLE for the same reason. Add this check to isotp_setsockopt_locked() and return -EAGAIN, so the socket options can only be changed when no transfer is active. As the transmission and the reception always end by their timeouts at the latest, this state is only temporary.

---
 net/can/isotp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
net/can/isotp.c +8 -0
index 0293d590186c..32c88749d75e 100644
@@ -1725,6 +1725,14 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname,
 	if (so->bound)
 		return -EISCONN;
 
+	/* A transmission or reception that outlived a previous binding
+	 * (unbound by NETDEV_UNREGISTER) may still be draining and uses the
+	 * socket options, see isotp_bind().
+	 */
+	if (READ_ONCE(so->tx.state) != ISOTP_IDLE ||
+	    READ_ONCE(so->rx.state) != ISOTP_IDLE)
+		return -EAGAIN;
+
 	switch (optname) {
 	case CAN_ISOTP_OPTS:
 		memcpy(&so->opt, val, sizeof(so->opt));
Signature · 1 line
2.53.0
#14 lore raw

Re: [PATCH net 07/11] can: isotp: reject socket options while a transfer is active

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] can: isotp: rxtimer left disarmed in isotp_rcv_cf() on invalid cf->len - [Medium] can: isotp…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] can: isotp: rxtimer left disarmed in isotp_rcv_cf() on invalid cf->len
- [Medium] can: isotp: isotp_sendmsg() reads socket options outside tx.state claim
--

commit 5df2197329153084f3880aee22e4689e00328a28
Author: Oliver Hartkopp <[email protected]>

can: isotp: reject socket options while a transfer is active

This commit rejects setsockopt() calls with -EAGAIN in isotp_setsockopt_locked() when so->tx.state or so->rx.state is not ISOTP_IDLE, preventing socket options from changing while a transfer from a previous binding is still draining.

Quoted 5 lines
net/can/isotp.c +0 -0
index 0293d590186c4..32c88749d75e7 100644

net/can/isotp.c static int isotp_setsockopt_locked(struct socket *sock, int optname, · line 1734

Quoted 10 lines
net/can/isotp.c +7 -0
@@ -1725,6 +1725,14 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname,
 	if (so->bound)
 		return -EISCONN;
 
+	/* A transmission or reception that outlived a previous binding
+	 * (unbound by NETDEV_UNREGISTER) may still be draining and uses the
+	 * socket options, see isotp_bind().
+	 */
+	if (READ_ONCE(so->tx.state) != ISOTP_IDLE ||
+	    READ_ONCE(so->rx.state) != ISOTP_IDLE)
+		return -EAGAIN;

[Severity: Medium]
Can an invalid consecutive frame leave so->rx.state permanently in ISOTP_WAIT_DATA with so->rxtimer disarmed, causing isotp_setsockopt_locked() (and isotp_bind()) to always return -EAGAIN after an unbind?

isotp_rcv_cf() cancels so->rxtimer before checking cf->len against so->rx.ll_dl, and returns early on a length mismatch without restarting so->rxtimer or resetting so->rx.state to ISOTP_IDLE:

net/can/isotp.c:isotp_rcv_cf() {
    ...
	hrtimer_cancel(&so->rxtimer);

	/* isotp_rx_timer_handler() may have raced us for so->rx.state
	 * while hrtimer_cancel() above waited for it to finish => recheck
	 */
	if (READ_ONCE(so->rx.state) != ISOTP_WAIT_DATA)
		return 1;

	/* CFs are never longer than the FF */
	if (cf->len > so->rx.ll_dl)
		return 1;

	/* CFs have usually the LL_DL length */
	if (cf->len < so->rx.ll_dl) {
		/* this is only allowed for the last CF */
		if (so->rx.len - so->rx.idx > so->rx.ll_dl - ae - N_PCI_SZ)
			return 1;
	}
    ...
}

If a peer sends a First Frame followed by a Consecutive Frame with an invalid length, so->rxtimer is disarmed while so->rx.state stays in ISOTP_WAIT_DATA, so the reception never times out.

[Severity: Medium]
Does isotp_sendmsg() still read socket options outside the region where so->tx.state is non-idle and so->bound is verified?

CPU0 CPU1
isotp_sendmsg()
ae = (so->opt.flags & ...)
wait_tx_done = (so->opt.flags & ...)
wait_event_interruptible(...)

                                      isotp_notify(NETDEV_UNREGISTER)
                                        so->bound = 0
                                      /* previous tx finishes:
                                       * so->tx.state = ISOTP_IDLE */
                                      isotp_setsockopt_locked()
                                        /* updates so->opt.flags */
                                      isotp_bind()
                                        so->bound = 1

WRITE_ONCE(so->tx.state, ISOTP_SENDING)
if (!READ_ONCE(so->bound)) ...
/* builds first frame with stale ae, while
* isotp_send_cframe() later reads new ae */

isotp_sendmsg() reads ae and wait_tx_done at function entry before claiming so->tx.state = ISOTP_SENDING and rechecking so->bound. In addition, at the end of isotp_sendmsg(), cf->flags = so->ll.tx_flags is read after publishing WRITE_ONCE(so->tx.state, new_state), starting tx_hrt, and dropping so->rx_lock, where an incoming FC abort or timeout can reset so->tx.state to ISOTP_IDLE and allow a concurrent setsockopt(CAN_ISOTP_LL_OPTS) after unbind to modify so->ll.tx_flags before cf->flags is assigned.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
#15 lore raw

Re: [PATCH net 07/11] can: isotp: reject socket options while a transfer is active

In reply to Marc Kleine-Budde
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [High] The new -EAGAIN check in isotp_setsockopt_locked() (net/can/isotp.c:1732-1734) assumes, as the commit message says, that…
- [Medium] isotp_sendmsg() reads so->opt.flags into 'ae' (CAN_ISOTP_EXTEND_ADDR) and 'wait_tx_done' (CAN_ISOTP_WAIT_TX_DONE) at…

--

can: isotp: reject socket options while a transfer is active

This commit adds a check to isotp_setsockopt_locked() that returns -EAGAIN while so->tx.state or so->rx.state is not ISOTP_IDLE. This matches the check already done in isotp_bind(). The goal is to stop a concurrent setsockopt() from changing so->opt, so->ll and so->tx.ll_dl while isotp_sendmsg() is still building frames after the device was unregistered.

Quoted 5 lines
net/can/isotp.c +0 -0
index 0293d590186c4..32c88749d75e7 100644

net/can/isotp.c static int isotp_setsockopt_locked(struct socket *sock, int optname, · line 1734

Quoted 10 lines
net/can/isotp.c +7 -0
@@ -1725,6 +1725,14 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname,
 	if (so->bound)
 		return -EISCONN;
 
+	/* A transmission or reception that outlived a previous binding
+	 * (unbound by NETDEV_UNREGISTER) may still be draining and uses the
+	 * socket options, see isotp_bind().
+	 */
+	if (READ_ONCE(so->tx.state) != ISOTP_IDLE ||
+	    READ_ONCE(so->rx.state) != ISOTP_IDLE)
+		return -EAGAIN;

[Severity: High]

The commit message says:

"As the transmission and the reception always end by their timeouts at the latest, this state is only temporary."

Is this true for the rx side?

In isotp_rcv_cf(), the rx watchdog is cancelled before the length checks. Two of the early exits that follow return without resetting so->rx.state and without re-arming so->rxtimer:

net/can/isotp.c:isotp_rcv_cf() {
    ...
	hrtimer_cancel(&so->rxtimer);
    ...
	/* CFs are never longer than the FF */
	if (cf->len > so->rx.ll_dl)
		return 1;

	/* CFs have usually the LL_DL length */
	if (cf->len < so->rx.ll_dl) {
		/* this is only allowed for the last CF */
		if (so->rx.len - so->rx.idx > so->rx.ll_dl - ae - N_PCI_SZ)
			return 1;
	}
    ...
}

This leaves the socket in ISOTP_WAIT_DATA with no timer armed, so isotp_rx_timer_handler() never runs to set it back to ISOTP_IDLE. While the socket is bound, the next SF or FF fixes the state through isotp_rcv_sf() or isotp_rcv_ff().

On NETDEV_UNREGISTER, isotp_notify() unregisters the isotp_rcv filter and clears so->bound, but it does not touch so->rx.state:

	so->ifindex = 0;
	WRITE_ONCE(so->bound, 0);
	WRITE_ONCE(so->dev, NULL);

After that, only isotp_release() can bring rx.state back to IDLE.

One possible sequence:

1) a node on the bus sends a valid FF; isotp_rcv_ff() sets WAIT_DATA and arms rxtimer
2) the same sender sends a malformed CF (classic CAN: a 3 byte CF while more than 7 bytes are still missing; CAN FD: an FF with len 8 followed by a 12 byte CF)
3) isotp_rcv_cf() cancels rxtimer and returns early, still in WAIT_DATA
4) the CAN device is unregistered (USB unplug, vcan/vxcan deletion, netns teardown)

Would every later setsockopt() on this socket then return -EAGAIN until the socket is closed?

The matching check in isotp_bind() would also keep returning -EAGAIN. The socket could then be neither reconfigured nor rebound.

An earlier commit in this series, "can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state", seems meant to close this class of stuck states. It only adds hrtimer_start() on the success paths of isotp_rcv_ff() and isotp_rcv_cf(), and these two early exits are not covered.

The isotp_bind() comment that this check points to makes the same assumption:

* (unbound by NETDEV_UNREGISTER) may still be draining; the FC/echo
* and RX watchdog timers bound how long this takes. Checked together

Could these exits re-arm rxtimer or reset rx.state to ISOTP_IDLE? Another option would be for isotp_notify() to cancel rxtimer and reset rx.state on NETDEV_UNREGISTER.

[Severity: Medium]

Does this check fully cover isotp_sendmsg()? The locals derived from the options are computed at function entry, before so->tx.state is claimed:

net/can/isotp.c:isotp_sendmsg() {
    ...
	int ae = (so->opt.flags & CAN_ISOTP_EXTEND_ADDR) ? 1 : 0;
	int wait_tx_done = (so->opt.flags & CAN_ISOTP_WAIT_TX_DONE) ? 1 : 0;
    ...
	/* so->bound is only checked once above - a wakeup may have
	 * unbound/rebound the socket meanwhile => recheck
	 */
	if (!READ_ONCE(so->bound)) {
    ...
}

The new check only rejects setsockopt() once tx.state != ISOTP_IDLE, so the window between function entry and the claim is not covered.

Here is how that could play out. isotp_sendmsg() is waiting in the claim loop (or is preempted) when the device is unregistered. Then setsockopt(CAN_ISOTP_OPTS) toggles CAN_ISOTP_EXTEND_ADDR or CAN_ISOTP_WAIT_TX_DONE, and bind() succeeds. In that case the bound recheck above passes.

The SF/FF size checks, isotp_fill_dataframe() and isotp_create_fframe() would then use the stale ae with the new so->tx.ll_dl and so->opt.ext_address. Meanwhile isotp_send_cframe() recomputes ae from the new flags:

	int ae = (so->opt.flags & CAN_ISOTP_EXTEND_ADDR) ? 1 : 0;

Could the FF and its CFs then use different extended addressing layouts within one PDU? And would the WAIT_TX_DONE blocking for that sendmsg() call still follow the old options?

This does not look like an out-of-bounds access. The indices stay bounded by so->tx.ll_dl, and the skb is sized from so->ll.mtu, which is read after the claim. It does not quite match the commit message's statement that "the socket options can only be changed when no transfer is active".

Would moving the ae and wait_tx_done computation after the claim, next to the bound recheck, close this window?

Quoted 4 lines
net/can/isotp.c +1 -0
+
 	switch (optname) {
 	case CAN_ISOTP_OPTS:
 		memcpy(&so->opt, val, sizeof(so->opt));
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117220818.1142581-2-mkl%40pengutronix.de
maintainer
#16 lore raw

Re: [PATCH net 07/11] can: isotp: reject socket options while a transfer is active

In general, a CAN_ISOTP socket whose bound CAN device has been removed or moved to another network namespace is unbound by isotp_notify() and reports ENODEV. A regular application sets the socket options once before bind() and closes the socket in this case. The scenarios with a concurrent setsockopt() and bind() on such a socket can only be created on purpose. They do not lead to memory corruption and affect at most the socket of the attacker and a single, possibly inconsistent, flow control frame on the attacker's own target CAN device.

Quoted 46 lines · On 18.11.26 23:19, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [High] The new -EAGAIN check in isotp_setsockopt_locked() (net/can/isotp.c:1732-1734) assumes, as the commit message says, that…
- [Medium] isotp_sendmsg() reads so->opt.flags into 'ae' (CAN_ISOTP_EXTEND_ADDR) and 'wait_tx_done' (CAN_ISOTP_WAIT_TX_DONE) at…

--

can: isotp: reject socket options while a transfer is active

This commit adds a check to isotp_setsockopt_locked() that returns -EAGAIN while so->tx.state or so->rx.state is not ISOTP_IDLE. This matches the check already done in isotp_bind(). The goal is to stop a concurrent setsockopt() from changing so->opt, so->ll and so->tx.ll_dl while isotp_sendmsg() is still building frames after the device was unregistered.

Quoted 5 lines
net/can/isotp.c +0 -0
index 0293d590186c4..32c88749d75e7 100644

net/can/isotp.c static int isotp_setsockopt_locked(struct socket *sock, int optname, · line 1734

Quoted 10 lines
net/can/isotp.c +7 -0
@@ -1725,6 +1725,14 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname,
  	if (so->bound)
  		return -EISCONN;
 
+	/* A transmission or reception that outlived a previous binding
+	 * (unbound by NETDEV_UNREGISTER) may still be draining and uses the
+	 * socket options, see isotp_bind().
+	 */
+	if (READ_ONCE(so->tx.state) != ISOTP_IDLE ||
+	    READ_ONCE(so->rx.state) != ISOTP_IDLE)
+		return -EAGAIN;

[Severity: High]

Quoted 6 lines

The commit message says:

"As the transmission and the reception always end by their timeouts at the latest, this state is only temporary."

Is this true for the rx side?

This is the same finding as for "can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state". I will send a separate patch that moves the length checks in isotp_rcv_cf() in front of hrtimer_cancel(), so that the rx state can not remain in ISOTP_WAIT_DATA without a running rx timeout. With this patch the statement in the commit message holds for the rx side as well.

Quoted 100 lines

In isotp_rcv_cf(), the rx watchdog is cancelled before the length checks. Two of the early exits that follow return without resetting so->rx.state and without re-arming so->rxtimer:

net/can/isotp.c:isotp_rcv_cf() {
     ...
	hrtimer_cancel(&so->rxtimer);
     ...
	/* CFs are never longer than the FF */
	if (cf->len > so->rx.ll_dl)
		return 1;

	/* CFs have usually the LL_DL length */
	if (cf->len < so->rx.ll_dl) {
		/* this is only allowed for the last CF */
		if (so->rx.len - so->rx.idx > so->rx.ll_dl - ae - N_PCI_SZ)
			return 1;
	}
     ...
}

This leaves the socket in ISOTP_WAIT_DATA with no timer armed, so isotp_rx_timer_handler() never runs to set it back to ISOTP_IDLE. While the socket is bound, the next SF or FF fixes the state through isotp_rcv_sf() or isotp_rcv_ff().

On NETDEV_UNREGISTER, isotp_notify() unregisters the isotp_rcv filter and clears so->bound, but it does not touch so->rx.state:

	so->ifindex = 0;
	WRITE_ONCE(so->bound, 0);
	WRITE_ONCE(so->dev, NULL);

After that, only isotp_release() can bring rx.state back to IDLE.

One possible sequence:

1) a node on the bus sends a valid FF; isotp_rcv_ff() sets WAIT_DATA and arms rxtimer
2) the same sender sends a malformed CF (classic CAN: a 3 byte CF while more than 7 bytes are still missing; CAN FD: an FF with len 8 followed by a 12 byte CF)
3) isotp_rcv_cf() cancels rxtimer and returns early, still in WAIT_DATA
4) the CAN device is unregistered (USB unplug, vcan/vxcan deletion, netns teardown)

Would every later setsockopt() on this socket then return -EAGAIN until the socket is closed?

The matching check in isotp_bind() would also keep returning -EAGAIN. The socket could then be neither reconfigured nor rebound.

An earlier commit in this series, "can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state", seems meant to close this class of stuck states. It only adds hrtimer_start() on the success paths of isotp_rcv_ff() and isotp_rcv_cf(), and these two early exits are not covered.

The isotp_bind() comment that this check points to makes the same assumption:

* (unbound by NETDEV_UNREGISTER) may still be draining; the FC/echo
* and RX watchdog timers bound how long this takes. Checked together

Could these exits re-arm rxtimer or reset rx.state to ISOTP_IDLE? Another option would be for isotp_notify() to cancel rxtimer and reset rx.state on NETDEV_UNREGISTER.

[Severity: Medium]

Does this check fully cover isotp_sendmsg()? The locals derived from the options are computed at function entry, before so->tx.state is claimed:

net/can/isotp.c:isotp_sendmsg() {
     ...
	int ae = (so->opt.flags & CAN_ISOTP_EXTEND_ADDR) ? 1 : 0;
	int wait_tx_done = (so->opt.flags & CAN_ISOTP_WAIT_TX_DONE) ? 1 : 0;
     ...
	/* so->bound is only checked once above - a wakeup may have
	 * unbound/rebound the socket meanwhile => recheck
	 */
	if (!READ_ONCE(so->bound)) {
     ...
}

The new check only rejects setsockopt() once tx.state != ISOTP_IDLE, so the window between function entry and the claim is not covered.

Here is how that could play out. isotp_sendmsg() is waiting in the claim loop (or is preempted) when the device is unregistered. Then setsockopt(CAN_ISOTP_OPTS) toggles CAN_ISOTP_EXTEND_ADDR or CAN_ISOTP_WAIT_TX_DONE, and bind() succeeds. In that case the bound recheck above passes.

The SF/FF size checks, isotp_fill_dataframe() and isotp_create_fframe() would then use the stale ae with the new so->tx.ll_dl and so->opt.ext_address. Meanwhile isotp_send_cframe() recomputes ae from the new flags:

Quoted 5 lines
	int ae = (so->opt.flags & CAN_ISOTP_EXTEND_ADDR) ? 1 : 0;

Could the FF and its CFs then use different extended addressing layouts within one PDU? And would the WAIT_TX_DONE blocking for that sendmsg() call still follow the old options?

The observation is correct, but it does not add a new kind of problem. It requires a concurrent setsockopt() and bind() on a socket whose CAN device vanished, while another thread waits in isotp_sendmsg(). As you already noted, there is no out-of-bounds access, and the result is at most one PDU with an inconsistent extended addressing on the attacker's own CAN device, which is the same class of effect as for a frame in flight described above.

Reading ae and wait_tx_done after the claim and the so->bound recheck would be a cleanup, which I will consider for can-next.

Best regards,
Oliver

Quoted 14 lines

This does not look like an out-of-bounds access. The indices stay bounded by so->tx.ll_dl, and the skb is sized from so->ll.mtu, which is read after the claim. It does not quite match the commit message's statement that "the socket options can only be changed when no transfer is active".

Would moving the ae and wait_tx_done computation after the claim, next to the bound recheck, close this window?

Quoted 4 lines
net/can/isotp.c +1 -0
+
  	switch (optname) {
  	case CAN_ISOTP_OPTS:
  		memcpy(&so->opt, val, sizeof(so->opt));
author maintainer
#17 lore raw

PATCH 8/11 can: netlink: fix static FD-NON-ISO mode validation

In reply to Marc Kleine-Budde

From: Zhu Ling <[email protected]>

Controllers with a static CAN_CTRLMODE_FD_NON_ISO mode (M_CAN v3.0.x and v3.1.x, PEAK pcan_usb_fd with firmware < 2.x) do not require the 'fd-non-iso' option to be provided when CAN FD is not switched on by the IFLA_CAN_CTRLMODE request.

Since commit 6742ca18cb41 ("can: netlink: add userland error messages") ctrlstatic_missing is calculated before this exception is applied to ctrlstatic, which is not evaluated afterwards. As a result every IFLA_CAN_CTRLMODE request on such controllers that does not contain 'fd-non-iso on' is rejected with -EOPNOTSUPP and "missing required FD-NON-ISO static control mode", e.g. 'fd off', 'loopback on' or 'one-shot on', regardless of the current CAN FD state.

Apply the exception to ctrlstatic_missing instead.

The exception must only relax the requirement to *provide* the static FD-NON-ISO mode. It must not allow to *switch off* a static mode: before the above mentioned commit a request like 'fd-non-iso off' passed the check and removed the static CAN_CTRLMODE_FD_NON_ISO bit from priv->ctrlmode. As can_get_static_ctrlmode() derives the static modes from priv->ctrlmode, this information was lost permanently. Therefore reject any request that explicitly switches off a static control mode with a dedicated error message. With this check in place a static mode can never be cleared by the 'priv->ctrlmode &= ~cm->mask' operation as every static bit in cm->mask is also set in maskedflags.

The request is rejected independent of the resulting CAN FD state, as accepting it while CAN FD is switched off would remove the static mode from priv->ctrlmode as well.

[Hartkopp: reject switching off static control modes instead of restoring
them, extend the commit message (Sashiko review)]

---
 drivers/net/can/dev/netlink.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/can/dev/netlink.c +9 -1
index 081dfddda000..521e2496e2cc 100644
@@ -330,9 +330,17 @@ static int can_ctrlmode_changelink(struct net_device *dev,
 		return -EOPNOTSUPP;
 	}
 
+	/* static control modes can not be switched off */
+	if (deactivated & ctrlstatic) {
+		NL_SET_ERR_MSG_FMT(extack,
+				   "static control mode %s can not be switched off",
+				   can_get_ctrlmode_str(deactivated & ctrlstatic));
+		return -EOPNOTSUPP;
+	}
+
 	/* do not check for static fd-non-iso if 'fd' is disabled */
 	if (!(maskedflags & CAN_CTRLMODE_FD))
-		ctrlstatic &= ~CAN_CTRLMODE_FD_NON_ISO;
+		ctrlstatic_missing &= ~CAN_CTRLMODE_FD_NON_ISO;
 
 	if (ctrlstatic_missing) {
 		NL_SET_ERR_MSG_FMT(extack,
Signature · 1 line
2.53.0
#18 lore raw

Re: [PATCH net 08/11] can: netlink: fix static FD-NON-ISO mode validation

Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…

Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch fixes a second, older bug but tags only the newer one.

--

can: netlink: fix static FD-NON-ISO mode validation

This patch moves the "fd is disabled" exception for the static FD-NON-ISO mode in can_ctrlmode_changelink() from ctrlstatic to ctrlstatic_missing. That stops requests such as 'fd off' or 'loopback on' from being rejected on controllers with a static FD-NON-ISO mode. It also adds a check that rejects any request which explicitly switches off a static control mode.

Quoted 5 lines
drivers/net/can/dev/netlink.c +0 -0
index 081dfddda0008..521e2496e2cc3 100644

drivers/net/can/dev/netlink.c static int can_ctrlmode_changelink(struct net_device *dev, · line 339

Quoted 10 lines
drivers/net/can/dev/netlink.c +7 -0
@@ -330,9 +330,17 @@ static int can_ctrlmode_changelink(struct net_device *dev,
 		return -EOPNOTSUPP;
 	}
 
+	/* static control modes can not be switched off */
+	if (deactivated & ctrlstatic) {
+		NL_SET_ERR_MSG_FMT(extack,
+				   "static control mode %s can not be switched off",
+				   can_get_ctrlmode_str(deactivated & ctrlstatic));
+		return -EOPNOTSUPP;
+	}

[Severity: Low]
Should this patch also carry a Fixes: tag for commit c9e1d8ed304c ("can:
dev: replace can_priv::ctrlmode_static by can_get_static_ctrlmode()")?

The commit message says this check closes a bug that existed before 6742ca18cb41:

"before the above mentioned commit a request like 'fd-non-iso off' passed the check and removed the static CAN_CTRLMODE_FD_NON_ISO bit from priv->ctrlmode. As can_get_static_ctrlmode() derives the static modes from priv->ctrlmode, this information was lost permanently."

The permanent loss comes from can_get_static_ctrlmode() in include/linux/can/dev.h, which was added by c9e1d8ed304c (v5.17):

    return priv->ctrlmode & ~priv->ctrlmode_supported;

Before c9e1d8ed304c, priv->ctrlmode_static was a separate field, so this path could not clear it.

In trees that have c9e1d8ed304c but not 6742ca18cb41, take M_CAN v3.0.x or v3.1.x, or pcan_usb_fd with firmware < 2.x. A request with mask=FD_NON_ISO, flags=0 and FD not switched on passes the check. Then 'priv->ctrlmode &= ~cm->mask' clears the static bit. A later 'fd on' is accepted and reported as ISO mode, while the hardware stays non-ISO.

The only tag is:

Fixes 6742ca18cb41 ("can: netlink: add userland error messages")

With only that tag, will the stable tooling skip this fix for LTS trees such as 6.1, 6.6 and 6.12? Those trees also lack ctrlstatic_missing, so the patch would not apply there as is.

Would a second Fixes: c9e1d8ed304c tag help here? Or a note that older trees need a separate backport?

Quoted 4 lines
drivers/net/can/dev/netlink.c +1 -1
 	/* do not check for static fd-non-iso if 'fd' is disabled */
 	if (!(maskedflags & CAN_CTRLMODE_FD))
-		ctrlstatic &= ~CAN_CTRLMODE_FD_NON_ISO;
+		ctrlstatic_missing &= ~CAN_CTRLMODE_FD_NON_ISO;

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117220818.1142581-2-mkl%40pengutronix.de
maintainer
#19 lore raw

Re: [PATCH net 08/11] can: netlink: fix static FD-NON-ISO mode validation

Quoted 65 lines · On 18.11.26 23:19, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch fixes a second, older bug but tags only the newer one.

--

can: netlink: fix static FD-NON-ISO mode validation

This patch moves the "fd is disabled" exception for the static FD-NON-ISO mode in can_ctrlmode_changelink() from ctrlstatic to ctrlstatic_missing. That stops requests such as 'fd off' or 'loopback on' from being rejected on controllers with a static FD-NON-ISO mode. It also adds a check that rejects any request which explicitly switches off a static control mode.

Quoted 5 lines
drivers/net/can/dev/netlink.c +0 -0
index 081dfddda0008..521e2496e2cc3 100644

drivers/net/can/dev/netlink.c static int can_ctrlmode_changelink(struct net_device *dev, · line 339

Quoted 10 lines
drivers/net/can/dev/netlink.c +7 -0
@@ -330,9 +330,17 @@ static int can_ctrlmode_changelink(struct net_device *dev,
  		return -EOPNOTSUPP;
  	}
 
+	/* static control modes can not be switched off */
+	if (deactivated & ctrlstatic) {
+		NL_SET_ERR_MSG_FMT(extack,
+				   "static control mode %s can not be switched off",
+				   can_get_ctrlmode_str(deactivated & ctrlstatic));
+		return -EOPNOTSUPP;
+	}

[Severity: Low]
Should this patch also carry a Fixes: tag for commit c9e1d8ed304c ("can:
dev: replace can_priv::ctrlmode_static by can_get_static_ctrlmode()")?

The commit message says this check closes a bug that existed before 6742ca18cb41:

"before the above mentioned commit a request like 'fd-non-iso off' passed the check and removed the static CAN_CTRLMODE_FD_NON_ISO bit from priv->ctrlmode. As can_get_static_ctrlmode() derives the static modes from priv->ctrlmode, this information was lost permanently."

The permanent loss comes from can_get_static_ctrlmode() in include/linux/can/dev.h, which was added by c9e1d8ed304c (v5.17):

     return priv->ctrlmode & ~priv->ctrlmode_supported;

Before c9e1d8ed304c, priv->ctrlmode_static was a separate field, so this path could not clear it.

In trees that have c9e1d8ed304c but not 6742ca18cb41, take M_CAN v3.0.x or v3.1.x, or pcan_usb_fd with firmware < 2.x. A request with mask=FD_NON_ISO, flags=0 and FD not switched on passes the check. Then 'priv->ctrlmode &= ~cm->mask' clears the static bit. A later 'fd on' is accepted and reported as ISO mode, while the hardware stays non-ISO.

The only tag is:

Quoted 8 lines
Fixes 6742ca18cb41 ("can: netlink: add userland error messages")

With only that tag, will the stable tooling skip this fix for LTS trees such as 6.1, 6.6 and 6.12? Those trees also lack ctrlstatic_missing, so the patch would not apply there as is.

Would a second Fixes: c9e1d8ed304c tag help here? Or a note that older trees need a separate backport?

No. Trees with c9e1d8ed304c but without 6742ca18cb41 can still lose the static FD-NON-ISO bit, but only after an explicit (and pointless) 'fd-non-iso off' while FD is not enabled. The common configurations ('fd on fd-non-iso on' and 'fd off') have always worked correctly there, and 'fd on' without 'fd-non-iso on' is rejected as intended.

Even in the corner case the hardware keeps running in non-ISO mode:
M_CAN v3.0.x/v3.1.x has no NISO bit (non-ISO is fixed in the IP), and pcan_usb_fd with firmware < 2.x never gets an ISO mode command. Only the reported ctrlmode would be wrong until the driver is reloaded.

So this is the only Fixes: tag needed. The regression that rejects valid configurations was introduced by 6742ca18cb41, and the stable backport follows that tag.

Best regards,
Oliver

Quoted 10 lines

drivers/net/can/dev/netlink.c static int can_ctrlmode_changelink(struct net_device *dev, · line 343

Quoted 5 lines
drivers/net/can/dev/netlink.c +1 -1
  	/* do not check for static fd-non-iso if 'fd' is disabled */
  	if (!(maskedflags & CAN_CTRLMODE_FD))
-		ctrlstatic &= ~CAN_CTRLMODE_FD_NON_ISO;
+		ctrlstatic_missing &= ~CAN_CTRLMODE_FD_NON_ISO;

[ ... ]

-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/
patchset/20261117220818.1142581-2-mkl%40pengutronix.de

author maintainer
#20 lore raw

PATCH 9/11 can: netlink: fix IFLA_CAN_BITRATE_MAX attribute sizing

In reply to Marc Kleine-Budde

From: Zhu Ling <[email protected]>

can_fill_info() emits IFLA_CAN_BITRATE_MAX with nla_put(), which consumes space for both the attribute header and its aligned payload. However, can_get_size() accounts for the payload only. The resulting underestimate can make filling the netlink response fail with -EMSGSIZE when the skb has no remaining slack.

Use nla_total_size() to account for the complete attribute.

---
 drivers/net/can/dev/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/dev/netlink.c +1 -1
index 521e2496e2cc..10e7ccaf40fb 100644
@@ -833,7 +833,7 @@ static size_t can_get_size(const struct net_device *dev)
 	if (priv->bitrate_const)				/* IFLA_CAN_BITRATE_CONST */
 		size += nla_total_size(sizeof(*priv->bitrate_const) *
 				       priv->bitrate_const_cnt);
-	size += sizeof(priv->bitrate_max);			/* IFLA_CAN_BITRATE_MAX */
+	size += nla_total_size(sizeof(priv->bitrate_max));	/* IFLA_CAN_BITRATE_MAX */
 	size += can_ctrlmode_ext_get_size();			/* IFLA_CAN_CTRLMODE_EXT */
 
 	size += can_data_bittiming_get_size(dev, &priv->fd,
Signature · 1 line
2.53.0
author maintainer
#21 lore raw

PATCH 10/11 can: netlink: fix CAN XL PWM attribute sizing

In reply to Marc Kleine-Budde

From: Zhu Ling <[email protected]>

can_pwm_fill_info() emits the PWM capability limits whenever pwm_const is present, regardless of whether TMS is enabled. In contrast, can_pwm_get_size() currently returns 0 when TMS is disabled. It therefore underestimates the required netlink message size by the nested attribute header and 6 u32 attributes.

Always account for the PWM capability attributes when pwm_const is present, and account for the 3 runtime PWM values only when TMS is enabled.

---
 drivers/net/can/dev/netlink.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/can/dev/netlink.c +6 -4
index 10e7ccaf40fb..7f597c975c6f 100644
@@ -791,7 +791,7 @@ static size_t can_pwm_get_size(const struct can_pwm_const *pwm_const,
 {
 	size_t size;
 
-	if (!pwm_const || !pwm_on)
+	if (!pwm_const)
 		return 0;
 
 	size = nla_total_size(0);			/* nest IFLA_CAN_PWM */
@@ -803,9 +803,11 @@ static size_t can_pwm_get_size(const struct can_pwm_const *pwm_const,
 	size += nla_total_size(sizeof(u32));		/* IFLA_CAN_PWM_PWMO_MIN */
 	size += nla_total_size(sizeof(u32));		/* IFLA_CAN_PWM_PWMO_MAX */
 
-	size += nla_total_size(sizeof(u32));		/* IFLA_CAN_PWM_PWMS */
-	size += nla_total_size(sizeof(u32));		/* IFLA_CAN_PWM_PWML */
-	size += nla_total_size(sizeof(u32));		/* IFLA_CAN_PWM_PWMO */
+	if (pwm_on) {
+		size += nla_total_size(sizeof(u32));	/* IFLA_CAN_PWM_PWMS */
+		size += nla_total_size(sizeof(u32));	/* IFLA_CAN_PWM_PWML */
+		size += nla_total_size(sizeof(u32));	/* IFLA_CAN_PWM_PWMO */
+	}
 
 	return size;
 }
Signature · 1 line
2.53.0
author maintainer
#22 lore raw

PATCH 11/11 can: gs_usb: gs_can_start_xmit(): don't leak uninitialized memory over USB

In reply to Marc Kleine-Budde

The driver allocates the transmission buffer using kmalloc(), which means the memory remains uninitialized. Then various headers are filled and, but only the actual CAN frame data payload (of length cfd->len or cf->len) is copied into the buffer, leaving the remaining buffer uninitialized.

Fix this information leak, allocate the buffer with kzalloc().

Fixes d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices")
---
 drivers/net/can/usb/gs_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/gs_usb.c +1 -1
index 3b9b2f104d86..15f28833f2de 100644
@@ -861,7 +861,7 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
 	if (!urb)
 		goto nomem_urb;
 
-	hf = kmalloc(dev->hf_size_tx, GFP_ATOMIC);
+	hf = kzalloc(dev->hf_size_tx, GFP_ATOMIC);
 	if (!hf)
 		goto nomem_hf;
 
Signature · 1 line
2.53.0
maintainer
#23 lore raw
In reply to Marc Kleine-Budde

Hi Marc,

unfortunately we did not make it into the net-PR for -rc4.

Do you want me to re-spin my series to address the Sashiko remarks and commit rewordings for this PR?

If so I would answer one of the reviews with a pw bot cr tag.

Best regards,
Oliver

Quoted 60 lines · Marc Kleine-Budde

Hello netdev-team,

this is a pull request of 11 patches for net/main.

The first 7 patches are by Oliver Hartkopp and avoid RTNL stalls in CAN_RAW, CAN_ISOTP and CAN_BCM protocols and fix CAN_ISOTP issues.

Followed by 3 patches are by Zhu Ling that fix problems with the CAN netlink handling.

A patch by my fixes a kernel memory information leak over USB in the gs_usb driver.

regards,
Marc

---

The following changes since commit 5e9b2ad9b8384cd3c417cd5e2c3bc7eee4a72791:

net/mlx5e: rep, Fix races between devcom PAIR event and uplink close (2026-11-17 16:12:52 +0100)

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-7.4-20261117

for you to fetch changes up to b772103b7a4feeee02fa12a3223a7fb5a5a8a81c:

   can: gs_usb: gs_can_start_xmit(): don't leak uninitialized memory over USB (2026-11-17 22:26:21 +0100)

----------------------------------------------------------------
linux-can-fixes-for-7.4-20261117

----------------------------------------------------------------
Marc Kleine-Budde (2):
Merge patch series "can: avoid RTNL stalls and fix CAN_ISOTP and netlink issues"
can: gs_usb: gs_can_start_xmit(): don't leak uninitialized memory over USB

Oliver Hartkopp (7):
can: bcm: copy the CAN frames outside of lock_sock()
can: bcm: do not remove the procfs entry in bcm_notify()
can: raw: use a private mutex instead of lock_sock()
can: isotp: use a private mutex instead of lock_sock()
can: bcm: use a private mutex instead of lock_sock()
can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state
can: isotp: reject socket options while a transfer is active

Zhu Ling (3):
can: netlink: fix static FD-NON-ISO mode validation
can: netlink: fix IFLA_CAN_BITRATE_MAX attribute sizing
can: netlink: fix CAN XL PWM attribute sizing

  drivers/net/can/dev/netlink.c |  22 +++++---
  drivers/net/can/usb/gs_usb.c  |   2 +-
  net/can/bcm.c                 | 114 ++++++++++++++++++++++++++++++------------
  net/can/isotp.c               |  50 +++++++++++-------
  net/can/raw.c                 |  41 ++++++++-------
  5 files changed, 153 insertions(+), 76 deletions(-)
author maintainer
#24 lore raw
Quoted 6 lines · Oliver Hartkopp

unfortunately we did not make it into the net-PR for -rc4.

Do you want me to re-spin my series to address the Sashiko remarks and commit rewordings for this PR?

If so I would answer one of the reviews with a pw bot cr tag.

make it so

regards,
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   |
maintainer
#25 lore raw

Hi Marc,

Quoted 10 lines · Marc Kleine-Budde
Quoted 6 lines · Oliver Hartkopp

unfortunately we did not make it into the net-PR for -rc4.

Do you want me to re-spin my series to address the Sashiko remarks and commit rewordings for this PR?

If so I would answer one of the reviews with a pw bot cr tag.

make it so

If it works for you, I would appreciate it if you could send the updated pull request today, so that I can address the feedback expected from the sashiko-bot.

My updated patches have been already reviewed and answered here:

https://lore.kernel.org/linux-can/[email protected]/

Best regards,
Oliver

author maintainer
#26 lore raw
Quoted 5 lines · Oliver Hartkopp
Quoted 2 lines

make it so

If it works for you, I would appreciate it if you could send the updated pull request today, so that I can address the feedback expected from the sashiko-bot.

tags/linux-can-fixes-for-7.4-20261124 is already pushed, just writing the summary.

Quoted 3 lines

My updated patches have been already reviewed and answered here:

https://lore.kernel.org/linux-can/[email protected]/

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   |
maintainer
#27 lore raw
Quoted 9 lines · Marc Kleine-Budde
Quoted 5 lines · Oliver Hartkopp
Quoted 2 lines

make it so

If it works for you, I would appreciate it if you could send the updated pull request today, so that I can address the feedback expected from the sashiko-bot.

tags/linux-can-fixes-for-7.4-20261124 is already pushed, just writing the summary.

Excellent!

Many thanks!

Best regards,
Oliver

Quoted 7 lines
Quoted 4 lines

My updated patches have been already reviewed and answered here:

https://lore.kernel.org/linux-can/[email protected]/

Marc