From: sashiko-bot@kernel.org
To: Biju <biju.das.au@gmail.com>
Cc: "Oliver Hartkopp" <socketcan@hartkopp.net>,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
wsa+renesas@sang-engineering.com,
"Vincent Mailhol" <mailhol@kernel.org>,
linux-can@vger.kernel.org
Subject: Re: [PATCH 3/3] can: rcar_canfd: Fix interrupt registration order
Date: Tue, 30 Jun 2026 14:05:24 +0000 [thread overview]
Message-ID: <20260630140525.8FBF11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260630135119.104774-4-biju.das.jz@bp.renesas.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Premature UAPI exposure causes unhandled hardware interrupts (IRQ storm).
Pre-existing issues:
- [High] Use-After-Free in global interrupt handlers during driver removal and error paths.
- [High] NULL pointer dereference due to early channel IRQ registration.
--
commit a0e1233eee22a1c4cd2d28a4473c39b527927759
Author: Biju Das <biju.das.jz@bp.renesas.com>
can: rcar_canfd: Fix interrupt registration order
In rcar_canfd_probe(), global interrupts are requested via
devm_request_irq() before rcar_canfd_global_init() enables the clocks
and before the per-channel structures in gpriv->ch[] are allocated.
> diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> index 1f3dc4b354f87..48f624c1eda9a 100644
> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
> @@ -2216,6 +2216,17 @@ static int rcar_canfd_probe(struct platform_device *pdev)
> gpriv->base = addr;
> gpriv->fcbase = addr + gpriv->info->regs->coffset;
>
> + err = rcar_canfd_global_init(gpriv);
> + if (err)
> + goto fail_dev;
> +
> + for_each_set_bit(ch, &gpriv->channels_mask, info->max_channels) {
> + err = rcar_canfd_channel_probe(gpriv, ch, fcan_freq,
> + transceivers[ch]);
[Severity: High]
Does moving rcar_canfd_channel_probe() before the global interrupt
registration expose the device to userspace prematurely?
rcar_canfd_channel_probe() calls register_candev(), which makes the network
device visible. If a userspace daemon immediately brings the interface up, it
can transition to operational mode and receive CAN frames, asserting the
global receive interrupt before devm_request_irq() has registered the global
handler.
Could this lead to an unhandled hardware interrupt storm that permanently
disables the CAN interrupt line?
[Severity: High]
This is a pre-existing issue, but does rcar_canfd_channel_probe() suffer
from the exact same early interrupt registration bug being fixed here?
Inside rcar_canfd_channel_probe(), when multi_channel_irqs is enabled,
devm_request_irq() is called for the channel error interrupt before the
channel pointer is stored:
drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_channel_probe() {
...
err = devm_request_irq(dev, err_irq, rcar_canfd_channel_err_interrupt,
...);
...
gpriv->ch[priv->channel] = priv;
}
If a pending interrupt fires immediately, the handler calls
rcar_canfd_handle_channel_err(), which dereferences gpriv->ch[ch].
Since gpriv->ch[ch] is still NULL, will this result in a kernel panic?
> + if (err)
> + goto fail_channel;
> + }
> +
> /* Request IRQ that's common for both channels */
> if (info->shared_global_irqs) {
> err = devm_request_irq(dev, ch_irq,
> @@ -2224,7 +2235,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
> if (err) {
> dev_err(dev, "devm_request_irq %d failed: %pe\n",
> ch_irq, ERR_PTR(err));
> - goto fail_dev;
> + goto fail_channel;
[Severity: High]
This is a pre-existing issue, but does the fail_channel error path have a
use-after-free race condition?
When tearing down the channels, rcar_canfd_channel_remove() calls
free_candev() but does not clear the gpriv->ch[ch] pointer:
drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_channel_remove() {
...
free_candev(priv->ndev);
// gpriv->ch[ch] is left dangling
}
Since global interrupts remain enabled until rcar_canfd_global_deinit() runs
after the channel loop, if a global receive interrupt fires for an active
channel, the handler rcar_canfd_global_receive_fifo_interrupt() will iterate
over all channels and dereference the dangling gpriv->ch[ch] pointer.
Can this cause a kernel crash if CAN traffic is present during the error
path or driver removal?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630135119.104774-1-biju.das.jz@bp.renesas.com?part=3
prev parent reply other threads:[~2026-06-30 14:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 13:51 [PATCH 0/3] Renesas CANFD Fixes Biju
2026-06-30 13:51 ` [PATCH 1/3] can: rcar_canfd: Fix dangling pointer on channel probe failure Biju
2026-06-30 13:59 ` sashiko-bot
2026-06-30 13:51 ` [PATCH 2/3] can: rcar_canfd: Fix double-cleanup and unclocked register access on init failure Biju
2026-06-30 14:06 ` sashiko-bot
2026-06-30 13:51 ` [PATCH 3/3] can: rcar_canfd: Fix interrupt registration order Biju
2026-06-30 14:05 ` sashiko-bot [this message]
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=20260630140525.8FBF11F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=biju.das.au@gmail.com \
--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=wsa+renesas@sang-engineering.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