From: netdev-bot+sashiko@kernel.org
To: mkl@pengutronix.de
Cc: mailhol@kernel.org, pfink@christ-es.de, eric@evenchick.com,
max@schneidersoft.net, wg@grandegger.com, kernel@pengutronix.de,
linux-can@vger.kernel.org, stable@vger.kernel.org,
kuba@kernel.org
Subject: Re: [PATCH can-next v10 05/14] can: gs_usb: fix hardware timestamp state for mixed channels
Date: Tue, 24 Nov 2026 09:30:56 +0000 [thread overview]
Message-ID: <179551265661.3131.9121195539625576936@kernel.org> (raw)
In-Reply-To: <20261122-gs_usb-fixes-v10-5-7c165c35d04a@pengutronix.de>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message does not say what actually goes wrong before
this fix.
--
can: gs_usb: fix hardware timestamp state for mixed channels
This patch moves the HW timestamp setup (cyclecounter and delayed work
init) into gs_usb_probe(). The setup now runs if any channel advertises
GS_CAN_FEATURE_HW_TIMESTAMP. Start and stop are keyed on a new
parent->flags bit rather than on the feature flags of the first channel
opened or the last channel closed.
Closes: https://sashiko.dev/#/bug/linux-b39360f9-6cd8-4f47-83bb-f0f78331f308
Closes: https://sashiko.dev/#/bug/linux-5f8ecd4e-344e-4ceb-9b46-886f4942a5f6
> Currently both the initialization and shutdown of the HW timestamping
> infrastructure is tied to the flags of the first channel opened
> respectively last channel closed. This leads to problems if the first
> channel opened doesn't have the timestamping feature, but the second
> channel has. In this case the timestamping is never properly initialized.
[Severity: Low]
This isn't a bug, but could the commit message say what actually goes
wrong before this fix? "Leads to problems" and "never properly
initialized" don't tell a stable reader how serious the fixed bugs are.
Both orderings look like memory-safety bugs in the old code.
In the first case, a channel without HW timestamps opens first and a
channel with HW timestamps opens second. gs_usb_timestamp_init() never
runs, so parent->tc.cc stays NULL and tc_lock is never initialized. An
RX or echo frame on the second channel still passes the
dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP check and ends up in:
gs_usb_set_timestamp()
gs_usb_skb_set_timestamp()
timecounter_cyc2time()
timecounter_cyc2time() reads tc->cc->mask. Isn't that a NULL pointer
dereference in URB completion context?
In the second case, a channel with HW timestamps opens first, so the
timestamp state is initialized and the delayed work is scheduled. Then
a channel without HW timestamps opens, the first channel closes, and
the second channel closes last.
The old gs_can_close() checked only the last channel's dev->feature, so
gs_usb_timestamp_stop() was never called:
if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP)
gs_usb_timestamp_stop(parent);
gs_usb_timestamp_work() re-arms itself unconditionally, and the old
gs_usb_disconnect() calls kfree(parent) without cancelling the work.
Wouldn't the delayed work embedded in parent then run after parent has
been freed?
In the same scenario, re-opening the first channel calls
spin_lock_init() and INIT_DELAYED_WORK() again while the work is still
pending.
The code changes appear to fix all of these. Would it be worth naming
the NULL pointer oops and the delayed work use-after-free in the commit
message?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122-gs_usb-fixes-v10-0-7c165c35d04a%40pengutronix.de
prev parent reply other threads:[~2026-11-24 9:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 18:48 [PATCH can-next v10 00/14] gs_usb: fixes Marc Kleine-Budde
2026-11-22 18:48 ` [PATCH can-next v10 01/14] can: gs_usb: gs_usb_probe(): init netdev completely before register_candev() Marc Kleine-Budde
2026-11-22 18:48 ` [PATCH can-next v10 02/14] can: gs_usb: gs_usb_receive_bulk_callback(): check for overflow flag if SKB allocation fails Marc Kleine-Budde
2026-11-24 9:30 ` netdev-bot+sashiko
2026-11-22 18:48 ` [PATCH can-next v10 03/14] can: gs_usb: gs_usb_receive_bulk_callback(): add missing call to can_rx_offload_irq_finish Marc Kleine-Budde
2026-11-22 18:48 ` [PATCH can-next v10 04/14] can: gs_usb: use spin_lock_irqsave() instead of spin_lock_bh() to protect struct gs_usb::tc Marc Kleine-Budde
2026-11-24 9:30 ` netdev-bot+sashiko
2026-11-22 18:48 ` [PATCH can-next v10 05/14] can: gs_usb: fix hardware timestamp state for mixed channels Marc Kleine-Budde
2026-11-24 9:30 ` netdev-bot+sashiko [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=179551265661.3131.9121195539625576936@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=eric@evenchick.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=max@schneidersoft.net \
--cc=mkl@pengutronix.de \
--cc=pfink@christ-es.de \
--cc=stable@vger.kernel.org \
--cc=wg@grandegger.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