From: sashiko-bot@kernel.org
To: "Oliver Hartkopp" <socketcan@hartkopp.net>
Cc: "Oliver Hartkopp" <socketcan@hartkopp.net>,
linux-can@vger.kernel.org,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH v4 1/7] can: bcm: defer rx_op deallocation to workqueue to fix thrtimer UAF
Date: Tue, 07 Jul 2026 14:47:38 +0000 [thread overview]
Message-ID: <20260707144738.735321F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260707-bcm_fixes-v4-1-aa87b8b9d33f@hartkopp.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent procfs reads can crash the kernel due to unsafe lockless list operations on `bo->rx_ops` and `bo->tx_ops`.
--
--- Patch [1]: [PATCH v4 1/7] can: bcm: defer rx_op deallocation to workqueue to fix thrtimer UAF ---
commit 784fd8a5d6989051af26ae5075b37f80eb5ecce7
Author: Lee Jones <lee@kernel.org>
can: bcm: defer rx_op deallocation to workqueue to fix thrtimer UAF
This commit resolves a use-after-free issue by deferring the cancellation
of timers and the deallocation of BCM operations to an unbound workqueue.
It takes an additional socket reference to ensure the socket outlives the
deferred work.
> diff --git a/net/can/bcm.c b/net/can/bcm.c
> index a4bef2c48a559..bdf53241bd7b3 100644
> --- a/net/can/bcm.c
> +++ b/net/can/bcm.c
[ ... ]
> @@ -1060,6 +1081,7 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
>
> /* bcm_can_tx / bcm_tx_timeout_handler needs this */
> op->sk = sk;
> + sock_hold(sk);
> op->ifindex = ifindex;
>
> /* initialize uninitialized (kzalloc) structure */
[Severity: High]
This is a pre-existing issue, but can concurrent procfs reads crash the kernel
due to unsafe lockless list operations on bo->tx_ops?
Later in bcm_tx_setup(), the new op is added to the list:
list_add(&op->list, &bo->tx_ops);
However, bcm_proc_show() locklessly iterates bo->tx_ops using the non-RCU
macro list_for_each_entry() instead of list_for_each_entry_rcu(), and
bcm_tx_setup() uses list_add() instead of list_add_rcu(). Because list_add()
lacks the smp_store_release() memory barrier of list_add_rcu(), and because
the tx_ops traversal lacks rcu_dereference() to enforce data dependencies,
the reader CPU can observe the new list node before its fields or next
pointer are initialized.
Could this lead to dereferencing uninitialized memory or a corrupted next
pointer if a local user repeatedly reads /proc/net/can-bcm/<inode> while a
thread creates new TX operations via sendmsg()?
[ ... ]
> @@ -1221,6 +1243,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
>
> /* bcm_can_tx / bcm_tx_timeout_handler needs this */
> op->sk = sk;
> + sock_hold(sk);
> op->ifindex = ifindex;
[Severity: High]
This is also a pre-existing issue, but a similar hazard exists for bo->rx_ops.
Later in bcm_rx_setup(), the code inserts into the list without RCU barriers:
list_add(&op->list, &bo->rx_ops);
While bcm_proc_show() does use list_for_each_entry_rcu() for rx_ops (unlike
tx_ops), bcm_rx_setup() still uses list_add() instead of list_add_rcu().
Without the smp_store_release() memory barrier provided by list_add_rcu(),
concurrent procfs reads can still observe the new node before its contents
are fully initialized.
Should these insertions be upgraded to use list_add_rcu() to match the
lockless RCU iteration in procfs?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707-bcm_fixes-v4-0-aa87b8b9d33f@hartkopp.net?part=1
next prev parent reply other threads:[~2026-07-07 14:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 14:32 [PATCH v4 0/7] can: bcm: collected fixes 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 via B4 Relay
2026-07-07 14:47 ` sashiko-bot [this message]
2026-07-07 14:32 ` [PATCH v4 2/7] can: bcm: fix lockless bound/ifindex race and silent RX_SETUP failure 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 via B4 Relay
2026-07-07 14:48 ` sashiko-bot
2026-07-07 14:32 ` [PATCH v4 4/7] can: bcm: fix CAN frame rx/tx statistics 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 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 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 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=20260707144738.735321F00A3F@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