From: sashiko-bot@kernel.org
To: "Oliver Hartkopp" <socketcan@hartkopp.net>, linux-can@vger.kernel.org
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH v6 7/8] can: isotp: reject socket options while a transfer is active
Date: Tue, 17 Nov 2026 17:17:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-219222@kernel.org> (raw)
In-Reply-To: <20261117-can-bcmlock-memcg-v6-7-6826a6227d36@hartkopp.net>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] can: isotp: race in isotp_setsockopt_locked() while rx.state
is ISOTP_IDLE
--
commit 2bbcd6c26df0af71086da24b238251d946bf05f7
Author: Oliver Hartkopp <socketcan@hartkopp.net>
can: isotp: reject socket options while a transfer is active
This commit rejects changing CAN_ISOTP socket options in
isotp_setsockopt_locked() when so->tx.state or so->rx.state is not
ISOTP_IDLE.
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index 0293d590186c4..32c88749d75e7 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -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 isotp_setsockopt_locked() still race with an in-flight isotp_rcv()
handler while so->rx.state is ISOTP_IDLE?
isotp_notify() clears so->bound on NETDEV_UNREGISTER without waiting for
an RCU grace period or acquiring so->rx_lock. Meanwhile, isotp_rcv_ff()
resets so->rx.state to ISOTP_IDLE before sending an overflow Flow Control
frame or transitioning to ISOTP_WAIT_DATA, and isotp_rcv_cf() sets
so->rx.state to ISOTP_IDLE before checking padding options. Because
isotp_setsockopt_locked() and isotp_bind() check so->rx.state without
holding so->rx_lock, a concurrent setsockopt() can still modify so->ll.mtu
between alloc_skb() and skb_put_zero() in isotp_send_fc():
CPU0 (<softirq>) CPU1
isotp_rcv()
spin_lock(&so->rx_lock)
isotp_rcv_ff()
WRITE_ONCE(so->rx.state, ISOTP_IDLE)
isotp_notify(NETDEV_UNREGISTER)
so->bound = 0
isotp_send_fc(..., ISOTP_FC_OVFLW)
alloc_skb(so->ll.mtu, ...)
/* allocated with CAN_MTU (16) */
isotp_setsockopt_locked(CAN_ISOTP_LL_OPTS)
/* rx.state is ISOTP_IDLE */
so->ll.mtu = CANFD_MTU (72)
isotp_bind()
so->ifindex = ...
dev = dev_get_by_index(...)
skb_put_zero(nskb, so->ll.mtu)
<-- skb_over_panic (72 > 16)
Acquiring so->rx_lock around the state check and option update (or
waiting for in-flight RCU readers on unbind) would close this window.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-can-bcmlock-memcg-v6-0-6826a6227d36@hartkopp.net?part=7
next prev parent reply other threads:[~2026-11-17 17:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 16:35 [PATCH v6 0/8] can: avoid RTNL stalls and fix CAN_ISOTP and netlink issues Oliver Hartkopp
2026-11-17 16:35 ` [PATCH v6 1/8] can: bcm: copy the CAN frames outside of lock_sock() Oliver Hartkopp
2026-11-17 16:35 ` [PATCH v6 2/8] can: bcm: do not remove the procfs entry in bcm_notify() Oliver Hartkopp
2026-11-19 6:59 ` netdev-bot+sashiko
2026-11-17 16:35 ` [PATCH v6 3/8] can: raw: use a private mutex instead of lock_sock() Oliver Hartkopp
2026-11-19 6:59 ` netdev-bot+sashiko
2026-11-17 16:35 ` [PATCH v6 4/8] can: isotp: " Oliver Hartkopp
2026-11-17 16:35 ` [PATCH v6 5/8] can: bcm: " Oliver Hartkopp
2026-11-17 16:35 ` [PATCH v6 6/8] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state Oliver Hartkopp
2026-11-19 6:59 ` netdev-bot+sashiko
2026-11-17 16:35 ` [PATCH v6 7/8] can: isotp: reject socket options while a transfer is active Oliver Hartkopp
2026-11-17 17:17 ` sashiko-bot [this message]
2026-11-17 18:58 ` Oliver Hartkopp
2026-11-19 6:59 ` netdev-bot+sashiko
2026-11-17 16:35 ` [PATCH v6 8/8] can: netlink: fix static FD-NON-ISO mode validation Oliver Hartkopp
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-219222@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox