From: sashiko-bot@kernel.org
To: "Vasileios Almpanis" <vasilisalmpanis@gmail.com>
Cc: "Vincent Mailhol" <mailhol@kernel.org>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
linux-can@vger.kernel.org,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH] can: isotp: hold a reference to the bound netdevice
Date: Tue, 16 Jun 2026 12:53:50 +0000 [thread overview]
Message-ID: <20260616125350.B7A371F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616123915.674534-1-vasilisalmpanis@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Calling synchronize_rcu() while holding rtnl_lock() introduces severe latency spikes and potential denial of service system-wide.
Pre-existing issues:
- [Critical] Skipping synchronize_rcu() in isotp_release() when the socket is unbound leads to a use-after-free of the socket structure by re-armed hrtimers.
--
commit da93bcd8877d85ffe0b043e3045c3374b10e38e5
Author: Vasileios Almpanis <vasilisalmpanis@gmail.com>
can: isotp: hold a reference to the bound netdevice
isotp_release() looked up the bound netdevice with
dev_get_by_index(so->ifindex) and only unregistered the socket's CAN
receivers if that lookup succeeded. This is unreliable while the device
is going away.
Cc: stable@vger.kernel.org
Closes: https://syzkaller.appspot.com/bug?id=58676a0f698531996a42612c552e894a55b9732b
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index c48b4a818297e..308d18040b6db 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -1219,27 +1222,22 @@ static int isotp_release(struct socket *sock)
> list_del(&so->notifier);
> spin_unlock(&isotp_notifier_lock);
>
> + rtnl_lock();
> lock_sock(sk);
>
> /* remove current filters & unregister */
> - if (so->bound) {
[ ... ]
> + if (so->bound && so->dev) {
> + if (isotp_register_rxid(so))
> + can_rx_unregister(net, so->dev, so->rxid,
> + SINGLE_MASK(so->rxid),
> + isotp_rcv, sk);
> +
> + can_rx_unregister(net, so->dev, so->txid,
> + SINGLE_MASK(so->txid),
> + isotp_rcv_echo, sk);
> + netdev_put(so->dev, &so->dev_tracker);
> + so->dev = NULL;
> + synchronize_rcu();
[Severity: High]
Does holding rtnl_lock() in isotp_release() (net/can/isotp.c) across
synchronize_rcu() cause severe latency spikes and potential denial of
service system-wide?
synchronize_rcu() blocks until all currently active RCU read-side critical
sections across the system finish, which stalls all other network
configuration operations while rtnl_lock() is held.
[Severity: Critical]
This is a pre-existing issue, but skipping synchronize_rcu() when the socket
is already unbound (e.g., by NETDEV_UNREGISTER where isotp_notify() sets
so->bound = 0) appears to allow a use-after-free.
If synchronize_rcu() is bypassed, isotp_release() proceeds to cancel the
socket's hrtimers and drop the user reference without waiting for concurrent
receive operations to complete.
Could a concurrent CAN receive operation like isotp_rcv_ff() or
isotp_rcv_echo() executing within an RCU read-side critical section
unconditionally re-arm the hrtimer after isotp_release() has cancelled it,
leading to a use-after-free when the timer later fires on the freed socket
memory?
> }
>
> hrtimer_cancel(&so->txfrtimer);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260616123915.674534-1-vasilisalmpanis@gmail.com?part=1
next prev parent reply other threads:[~2026-06-16 12:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 12:39 [PATCH] can: isotp: hold a reference to the bound netdevice Vasileios Almpanis
2026-06-16 12:53 ` sashiko-bot [this message]
2026-06-16 14:57 ` Vasileios Almpanis
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=20260616125350.B7A371F000E9@smtp.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 \
--cc=vasilisalmpanis@gmail.com \
/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