From: Lee Jones <lee@kernel.org>
To: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>, linux-can@vger.kernel.org
Subject: Re: [PATCH v2] can: bcm: prevent thrtimer UAF in rx path by checking RX_NO_AUTOTIMER
Date: Thu, 15 Oct 2026 10:45:34 +0100 [thread overview]
Message-ID: <20261015094534.GE1182143@google.com> (raw)
In-Reply-To: <c03a99d4-5ae1-415c-9f3d-de6855755f93@hartkopp.net>
On Thu, 15 Oct 2026, Oliver Hartkopp wrote:
> Answering myself:
>
> This patch from Lee with READ_ONCE() and WRITE_ONCE() had been completely
> reworked to use a workqueue:
>
> "can: bcm: defer rx_op deallocation to workqueue to fix thrtimer UAF"
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=68973f9db76144825e4f35dfdc80fb8279eb2d57
>
> which is also from Lee and upstream as said.
>
> So THIS patch here is obsolete.
Thanks for the clarifications Oliver.
> p.s. And the READ_ONCE() and WRITE_ONCE() in this patch also became
> obsolete. It would have no effect for race conditions only for KCSAN
> annotations - which we do not have. So we are completely done.
>
>
> On 15.10.26 10:03, Oliver Hartkopp wrote:
> >
> >
> > On 15.10.26 09:34, Lee Jones wrote:
> > > On Thu, 15 Oct 2026, Marc Kleine-Budde wrote:
> > >
> > > > On 19.05.2026 13:38:05, Oliver Hartkopp wrote:
> > > > > From: Lee Jones <lee@kernel.org>
> > > > >
> > > > > Commit f1b4e32aca08 ("can: bcm: use call_rcu() instead of costly
> > > > > synchronize_rcu()") removed the synchronize_rcu() call from
> > > > > bcm_delete_rx_op() and introduced the RX_NO_AUTOTIMER flag to prevent
> > > > > timers from being rearmed during deletion. However, it only applied
> > > > > this check to op->timer via bcm_rx_starttimer().
> > > > >
> > > > > It missed the fact that op->thrtimer can also be rearmed by an
> > > > > in-flight bcm_rx_handler() (which runs as an RCU reader) via
> > > > > bcm_rx_update_and_send(). This allows op->thrtimer to be queued after
> > > > > bcm_remove_op() has already cancelled it, leading to a use-after-free
> > > > > when the timer fires on the deferred-freed struct bcm_op.
> > > > >
> > > > > Address the omission by checking the RX_NO_AUTOTIMER flag
> > > > > in bcm_rx_update_and_send() before starting op->thrtimer, effectively
> > > > > preventing it from being rearmed concurrently with teardown.
> > > > >
> > > > > [Hartkopp] Added the setting of RX_NO_AUTOTIMER also to
> > > > > bcm_release() before
> > > > > removing the CAN filters following the bcm_delete_rx_op() approach.
> > > > >
> > > > > Additionally WRITE_ONCE()/READ_ONCE() macros have been introduced for
> > > > > the changes of RX_NO_AUTOTIMER at rx op removal time to prevent a
> > > > > potential code reordering of RX_NO_AUTOTIMER setting after
> > > > > CAN filter removal.
> > > > >
> > > > > Signed-off-by: Lee Jones <lee@kernel.org>
> > > > > Co-developed-by: Oliver Hartkopp <socketcan@hartkopp.net>
> > > > > Fixes: f1b4e32aca08 ("can: bcm: use call_rcu() instead of
> > > > > costly synchronize_rcu()")
> > > > > Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> > > >
> > > > This patch is obsolete, right?
> > >
> > > No, I don't think so. I thought it was applied to the maintainer tree?
> > >
> >
> > I think it became obsolete through all the recent (and stable) changes
> > that addressed multiple races. The UAF problem is solved today.
> >
> > Btw. the use of READ_ONCE() and WRITE_ONCE() can be seen as some
> > addditional hardening but the entire patch does not fit to the current
> > bcm.c code.
> >
> > The READ_ONCE() and WRITE_ONCE() may be added for the 7.5 net-next
> > window cycle. No pressure here.
> >
> > Best regards,
> > Oliver
> >
> >
>
--
Lee Jones
prev parent reply other threads:[~2026-10-15 9:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 11:38 [PATCH v2] can: bcm: prevent thrtimer UAF in rx path by checking RX_NO_AUTOTIMER Oliver Hartkopp
2026-05-20 12:47 ` Lee Jones
2026-05-20 12:49 ` Lee Jones
2026-05-20 13:03 ` Oliver Hartkopp
2026-05-20 13:40 ` Lee Jones
2026-05-20 14:06 ` Lee Jones
2026-05-20 15:23 ` Oliver Hartkopp
2026-05-20 16:13 ` Lee Jones
2026-05-20 18:00 ` Oliver Hartkopp
2026-05-21 11:07 ` Lee Jones
2026-05-21 11:35 ` Oliver Hartkopp
2026-05-21 13:51 ` Lee Jones
2026-05-21 17:57 ` Oliver Hartkopp
2026-05-20 12:59 ` Oliver Hartkopp
2026-10-14 23:00 ` Marc Kleine-Budde
2026-10-15 7:34 ` Lee Jones
2026-10-15 8:03 ` Oliver Hartkopp
2026-10-15 8:44 ` Oliver Hartkopp
2026-10-15 9:45 ` Lee Jones [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=20261015094534.GE1182143@google.com \
--to=lee@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--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