From: sashiko-bot@kernel.org
To: "Oliver Hartkopp" <socketcan@hartkopp.net>
Cc: "Vincent Mailhol" <mailhol@kernel.org>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
linux-can@vger.kernel.org,
"Oliver Hartkopp" <socketcan@hartkopp.net>
Subject: Re: [PATCH v4 3/7] can: bcm: add locking when updating filter and timer values
Date: Tue, 07 Jul 2026 14:48:45 +0000 [thread overview]
Message-ID: <20260707144846.559ED1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260707-bcm_fixes-v4-3-aa87b8b9d33f@hartkopp.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Lockless reads of timer and state variables in `bcm_tx_timeout_handler()` cause torn reads and TOCTOU bugs.
--
--- Patch [3]: [PATCH v4 3/7] can: bcm: add locking when updating filter and timer values ---
commit 59929132ac1eda994b23441375ebf1eecf8fc14d
Author: Oliver Hartkopp <socketcan@hartkopp.net>
can: bcm: add locking when updating filter and timer values
KCSAN detected a simultaneous access to timer values that can be
overwritten in bcm_rx_setup() when updating timer and filter content
while bcm_rx_handler(), bcm_rx_timeout_handler() or bcm_rx_thr_handler()
run concurrently on incoming CAN traffic.
Reported-by: syzbot+75e5e4ae00c3b4bb544e@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-can/6975d5cf.a00a0220.33ccc7.0022.GAE@google.com/
> diff --git a/net/can/bcm.c b/net/can/bcm.c
> index b612135b017d1..b9b6f1b7bb03b 100644
> --- a/net/can/bcm.c
> +++ b/net/can/bcm.c
> @@ -461,7 +466,7 @@ static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer)
> struct bcm_msg_head msg_head;
>
> if (op->kt_ival1 && (op->count > 0)) {
[Severity: High]
This is a pre-existing issue, but while the patch adds locking to protect
timers in the RX path, it looks like a similar data race might exist here
in the TX path.
Can lockless reads of op->kt_ival1, op->kt_ival2, and op->count in
bcm_tx_timeout_handler() lead to torn reads on 32-bit systems?
Since bcm_tx_setup() updates these 64-bit timer intervals locklessly:
net/can/bcm.c:bcm_tx_setup() {
...
if (op->flags & SETTIMER) {
...
op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1);
op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2);
}
...
}
And bcm_tx_set_expiry() also reads them locklessly:
net/can/bcm.c:bcm_tx_set_expiry() {
...
if (op->kt_ival1 && op->count)
ival = op->kt_ival1;
else if (op->kt_ival2)
ival = op->kt_ival2;
...
}
Would it be possible for the hrtimer softirq context to see torn ktime_t
values if it preempts or runs concurrently with bcm_tx_setup()?
Could this lead to wildly incorrect timer expiry values that might stall
the cyclic transmission, or corrupt user notifications?
> - bcm_can_tx(op);
> + bcm_can_tx(op, NULL);
> if (!op->count && (op->flags & TX_COUNTEVT)) {
>
> /* create notification to user */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707-bcm_fixes-v4-0-aa87b8b9d33f@hartkopp.net?part=3
next prev parent reply other threads:[~2026-07-07 14:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 14:32 [PATCH v4 0/7] can: bcm: collected fixes Oliver Hartkopp
2026-07-07 14:32 ` Oliver Hartkopp via B4 Relay
2026-07-07 14:32 ` [PATCH v4 1/7] can: bcm: defer rx_op deallocation to workqueue to fix thrtimer UAF Oliver Hartkopp
2026-07-07 14:32 ` Oliver Hartkopp via B4 Relay
2026-07-07 14:47 ` sashiko-bot
2026-07-07 14:32 ` [PATCH v4 2/7] can: bcm: fix lockless bound/ifindex race and silent RX_SETUP failure Oliver Hartkopp
2026-07-07 14:32 ` Oliver Hartkopp via B4 Relay
2026-07-07 14:53 ` sashiko-bot
2026-07-07 14:32 ` [PATCH v4 3/7] can: bcm: add locking when updating filter and timer values Oliver Hartkopp
2026-07-07 14:32 ` Oliver Hartkopp via B4 Relay
2026-07-07 14:48 ` sashiko-bot [this message]
2026-07-07 14:32 ` [PATCH v4 4/7] can: bcm: fix CAN frame rx/tx statistics Oliver Hartkopp
2026-07-07 14:32 ` Oliver Hartkopp via B4 Relay
2026-07-07 14:54 ` sashiko-bot
2026-07-07 14:32 ` [PATCH v4 5/7] can: bcm: add missing rcu list annotations and operations Oliver Hartkopp
2026-07-07 14:32 ` Oliver Hartkopp via B4 Relay
2026-07-07 14:49 ` sashiko-bot
2026-07-07 14:32 ` [PATCH v4 6/7] can: bcm: extend bcm_tx_lock usage for data and timer updates Oliver Hartkopp
2026-07-07 14:32 ` Oliver Hartkopp via B4 Relay
2026-07-07 14:38 ` Marc Kleine-Budde
2026-07-07 14:48 ` Oliver Hartkopp
2026-07-07 14:32 ` [PATCH v4 7/7] can: bcm: validate frame length in bcm_rx_setup() for RTR replies Oliver Hartkopp
2026-07-07 14:32 ` Oliver Hartkopp via B4 Relay
2026-07-07 14:51 ` sashiko-bot
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=20260707144846.559ED1F00A3D@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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.