From: sashiko-bot@kernel.org
To: "Marc Kleine-Budde" <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH net 6/9] can: isotp: use a private mutex instead of lock_sock()
Date: Mon, 16 Nov 2026 09:58:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-216678@kernel.org> (raw)
In-Reply-To: <20261115095746.709371-7-mkl@pengutronix.de>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] can: isotp: missing active TX/RX state check in
isotp_setsockopt_locked() [1]
--
commit fb285f445bf95b5048922b684bed21d449cf9cea
Author: Oliver Hartkopp <socketcan@hartkopp.net>
can: isotp: use a private mutex instead of lock_sock()
This commit replaces lock_sock() in the CAN_ISOTP protocol with a private
conf_lock mutex in struct isotp_sock so generic SOL_SOCKET options that
sleep on user space access under sockopt_lock_sock() cannot block
isotp_notify() while holding RTNL.
Link: https://patch.msgid.link/20261113-can-bcmlock-memcg-v5-4-634c0e04bc72@hartkopp.net
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index 7a90ba3f1cf1c..8229b6a69ecd0 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
[ ... ]
> @@ -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;
> }
[Severity: High]
This problem wasn't introduced by this patch, but can
isotp_setsockopt_locked() [1] modify socket options while an ISO-TP
transfer is still active after NETDEV_UNREGISTER?
When a bound device is unregistered during a transfer, isotp_notify()
clears so->bound under so->conf_lock while the TX or RX state machine
continues running until its timers or work complete. Unlike isotp_bind(),
which rejects rebinding while so->tx.state or so->rx.state is not
ISOTP_IDLE, isotp_setsockopt_locked() only checks so->bound:
net/can/isotp.c:isotp_setsockopt_locked() {
if (so->bound)
return -EISCONN;
...
case CAN_ISOTP_LL_OPTS: {
...
memcpy(&so->ll, ll, sizeof(*ll));
/* set ll_dl for tx path to similar place as for rx */
so->tx.ll_dl = ll->tx_dl;
break;
}
}
A concurrent setsockopt() after NETDEV_UNREGISTER can therefore mutate
so->opt, so->rxfc, so->ll.mtu, and so->tx.ll_dl while frame construction
is in flight, causing data races and writing past skb->tail when
so->ll.mtu is reduced from CANFD_MTU to CAN_MTU mid-transfer. Should
isotp_setsockopt_locked() also check that so->tx.state and so->rx.state
are ISOTP_IDLE?
[1] https://sashiko.dev/#/bug/linux-d1d3ef49-c24e-4f3a-91ce-20f8fb222684
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115095746.709371-1-mkl@pengutronix.de?part=6
next prev parent reply other threads:[~2026-11-16 9:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 9:54 [PATCH net 0/9] pull-request: can 2026-11-15 Marc Kleine-Budde
2026-11-15 9:54 ` [PATCH net 1/9] can: bcm: copy the CAN frames outside of lock_sock() Marc Kleine-Budde
2026-11-15 9:54 ` [PATCH net 2/9] can: bcm: do not remove the procfs entry in bcm_notify() Marc Kleine-Budde
2026-11-15 9:54 ` [PATCH net 3/9] can: netlink: fix static FD-NON-ISO mode validation Marc Kleine-Budde
2026-11-17 16:46 ` Oliver Hartkopp
2026-11-15 9:54 ` [PATCH net 4/9] can: raw: use a private mutex instead of lock_sock() Marc Kleine-Budde
2026-11-15 9:54 ` [PATCH net 5/9] can: netlink: fix IFLA_CAN_BITRATE_MAX attribute sizing Marc Kleine-Budde
2026-11-15 9:54 ` [PATCH net 6/9] can: isotp: use a private mutex instead of lock_sock() Marc Kleine-Budde
2026-11-16 9:58 ` sashiko-bot [this message]
2026-11-16 16:59 ` Oliver Hartkopp
2026-11-17 16:41 ` Oliver Hartkopp
2026-11-15 9:54 ` [PATCH net 7/9] can: netlink: fix CAN XL PWM attribute sizing Marc Kleine-Budde
2026-11-15 9:54 ` [PATCH net 8/9] can: bcm: use a private mutex instead of lock_sock() Marc Kleine-Budde
2026-11-15 9:55 ` [PATCH net 9/9] can: gs_usb: gs_can_start_xmit(): don't leak uninitialized memory over USB Marc Kleine-Budde
2026-11-15 10:18 ` [PATCH net 0/9] pull-request: can 2026-11-15 Marc Kleine-Budde
2026-11-15 11:23 ` Oliver Hartkopp
2026-11-15 11:55 ` Marc Kleine-Budde
2026-11-15 20:10 ` netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-216678@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
--cc=socketcan@hartkopp.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.