From: sashiko-bot@kernel.org
To: "Oliver Hartkopp" <socketcan@hartkopp.net>
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
linux-can@vger.kernel.org, "Vincent Mailhol" <mailhol@kernel.org>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH v2 5/6] can: bcm: add missing rcu list annotations and operations
Date: Tue, 07 Jul 2026 08:50:16 +0000 [thread overview]
Message-ID: <20260707085016.7E0A11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707-bcm_fixes-v2-5-96620c534b75@hartkopp.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent updates to CAN frames and timers in bcm_tx_setup() race with bcm_tx_timeout_handler() and bcm_can_tx().
--
--- Patch [5]: [PATCH v2 5/6] can: bcm: add missing rcu list annotations and operations ---
commit 6cbc186daf031268589b88c789ab291e31165918
Author: Oliver Hartkopp <socketcan@hartkopp.net>
can: bcm: add missing rcu list annotations and operations
This commit adds missing list_add_rcu() calls in bcm_tx_setup() and
bcm_rx_setup() to ensure proper initialization of bcm_op structures during
RCU traversal. It also fixes the removal side in bcm_release() by properly
unlinking ops with list_del_rcu() before freeing them via call_rcu().
Closes: https://lore.kernel.org/linux-can/20260610094654.A1FFE1F00893@smtp.kernel.org/
> diff --git a/net/can/bcm.c b/net/can/bcm.c
> index 20b1bdc87414a..3609178a1367d 100644
> --- a/net/can/bcm.c
> +++ b/net/can/bcm.c
[ ... ]
> @@ -1156,6 +1156,10 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
> op->flags |= TX_ANNOUNCE;
> }
>
> + /* add this bcm_op to the list of the tx_ops? */
> + if (add_op_to_list)
> + list_add_rcu(&op->list, &bo->tx_ops);
> +
[Severity: High]
This is a pre-existing issue, but can concurrent updates to CAN frames and
timers in bcm_tx_setup() race with bcm_tx_timeout_handler() and
bcm_can_tx()?
While a previous commit in the series fixed this exact issue for RX ops by
using a staging buffer and lock, the TX path appears to be left unprotected.
When an existing BCM TX op is running its cyclic transmission via the
hrtimer bcm_tx_timeout_handler(), and user-space calls sendmsg() with
TX_SETUP to update the op's frames or timers, bcm_tx_setup() directly
copies new data into op->frames using memcpy_from_msg() without holding
bcm_tx_lock or using a staging buffer. It also updates op->kt_ival1 and
op->kt_ival2 without locking.
Concurrently, bcm_tx_timeout_handler() reads the unprotected timer values
and invokes bcm_can_tx().
bcm_can_tx() acquires bcm_tx_lock only to resolve the cf pointer to the
current frame, but drops the lock before calling skb_put_data().
Could this allow skb_put_data(skb, cf, op->cfsiz) to copy the frame payload
out of op->frames simultaneously with memcpy_from_msg() writing to it,
resulting in a torn read that transmits corrupt or partially updated CAN
frames onto the network?
> if (op->flags & TX_ANNOUNCE)
> bcm_can_tx(op, NULL);
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707-bcm_fixes-v2-0-96620c534b75@hartkopp.net?part=5
next prev parent reply other threads:[~2026-07-07 8:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 7:27 [PATCH v2 0/6] can: bcm: collected fixes Oliver Hartkopp via B4 Relay
2026-07-07 7:27 ` [PATCH v2 1/6] can: bcm: defer rx_op deallocation to workqueue to fix thrtimer UAF Oliver Hartkopp via B4 Relay
2026-07-07 7:59 ` sashiko-bot
2026-07-07 7:27 ` [PATCH v2 2/6] can: bcm: fix lockless bound/ifindex race and silent RX_SETUP failure Oliver Hartkopp via B4 Relay
2026-07-07 8:13 ` sashiko-bot
2026-07-07 7:27 ` [PATCH v2 3/6] can: bcm: add locking when updating filter and timer values Oliver Hartkopp via B4 Relay
2026-07-07 8:28 ` sashiko-bot
2026-07-07 7:27 ` [PATCH v2 4/6] can: bcm: fix CAN frame rx/tx statistics Oliver Hartkopp via B4 Relay
2026-07-07 8:37 ` sashiko-bot
2026-07-07 7:27 ` [PATCH v2 5/6] can: bcm: add missing rcu list annotations and operations Oliver Hartkopp via B4 Relay
2026-07-07 8:50 ` sashiko-bot [this message]
2026-07-07 7:27 ` [PATCH v2 6/6] can: bcm: extend bcm_tx_lock usage for data and timer updates Oliver Hartkopp via B4 Relay
2026-07-07 8:58 ` 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=20260707085016.7E0A11F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox