From: sashiko-bot@kernel.org
To: "Ji-Ze Hong (Peter Hong)" <peter_hong@fintek.com.tw>
Cc: linux-can@vger.kernel.org, "Vincent Mailhol" <mailhol@kernel.org>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH v2] can: usb: f81604: fix struct f81604_int_data size mismatch
Date: Mon, 24 Aug 2026 13:30:09 +0000 [thread overview]
Message-ID: <20260824133009.CF85A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260824-f81604-fix-v2-1-fc9be5581394@fintek.com.tw>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Improper teardown order in `f81604_close()` allows asynchronous work to be scheduled after `cancel_work_sync`, leading to a Use-After-Free on device disconnect.
--
--- Patch [1]: [PATCH v2] can: usb: f81604: fix struct f81604_int_data size mismatch ---
commit 975e1f8f6c4a34bb9458d846d2ded822cbc82f04
Author: Ji-Ze Hong (Peter Hong) <peter_hong@fintek.com.tw>
can: usb: f81604: fix struct f81604_int_data size mismatch
This commit removes the __aligned(4) attribute from struct f81604_int_data
so its size matches the actual 9-byte hardware data size. This prevents
valid interrupt messages from being incorrectly discarded as short URBs.
Closes: https://lore.kernel.org/all/A3834A07-5639-4779-844F-C5843DFC3928@dynetrex.com/
> diff --git a/drivers/net/can/usb/f81604.c b/drivers/net/can/usb/f81604.c
> index f12318268e46b..4c147b9d6d690 100644
> --- a/drivers/net/can/usb/f81604.c
> +++ b/drivers/net/can/usb/f81604.c
> @@ -169,7 +169,7 @@ struct f81604_int_data {
> u8 rxerr;
> u8 txerr;
> u8 val;
> -} __packed __aligned(4);
> +} __packed;
[Severity: High]
This is a pre-existing issue, but by fixing the struct size and enabling
normal interrupt processing, this patch actively unmasks a use-after-free
on device disconnect.
Looking at f81604_close(), cancel_work_sync() is called before the URBs
are unregistered:
drivers/net/can/usb/f81604.c:f81604_close() {
...
cancel_work_sync(&priv->clear_reg_work);
close_candev(netdev);
f81604_unregister_urbs(priv);
...
}
If an interrupt URB completes concurrently with a device disconnect,
could the URB completion handler schedule the work again after
cancel_work_sync() has already completed?
drivers/net/can/usb/f81604.c:f81604_handle_can_bus_errors() {
...
if (priv->clear_flags)
schedule_work(&priv->clear_reg_work);
...
}
If so, f81604_unregister_urbs() will wait for the URB callback to finish
but leave the newly scheduled work pending.
When the disconnect path returns and frees the netdev and its embedded
priv struct, will the delayed work execute and dereference the freed
pointer in f81604_clear_reg_work()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-f81604-fix-v2-1-fc9be5581394@fintek.com.tw?part=1
next prev parent reply other threads:[~2026-08-24 13:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 13:18 [PATCH v2] can: usb: f81604: fix struct f81604_int_data size mismatch Ji-Ze Hong via B4 Relay
2026-08-24 13:26 ` Greg Kroah-Hartman
2026-08-24 13:30 ` sashiko-bot [this message]
2026-08-24 15:11 ` Marc Kleine-Budde
2026-08-25 13:15 ` PS10 PETER HONG 洪繼澤
2026-08-24 15:11 ` Marc Kleine-Budde
2026-08-24 23:39 ` Drew Willey
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=20260824133009.CF85A1F00A3A@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=peter_hong@fintek.com.tw \
--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