Re: [PATCH] can: kvaser_pciefd: fix use-after-free in bec poll timer

Marc Kleine-Budde <[email protected]>
Newsgroups org.kernel.vger.linux-can,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <20260819-amethyst-spider-of-development-85130a-mkl@pengutronix.de>
On 18.08.2026 21:22:51, Fan Wu wrote:
> Hi Marc,
>
> Yes. The driver has three timer_delete() call sites, all for
> bec_poll_timer.
>
> The calls in kvaser_pciefd_bus_on() and kvaser_pciefd_stop() are runtime
> cancellations: the CAN device stays alive after both, and the timer must
> stay rearmable for the next open/bus-on cycle, since the interrupt
> handler arms it from handle_error_packet(), handle_status_resp() and
> handle_status_packet().  Converting either one to timer_shutdown_sync()
> would make those later mod_timer() calls no-ops.  The stop() flush-timeout
> path, which skips its timer_delete() entirely, is also covered: the device
> is still alive there, and remove() still shuts the timer down
> unconditionally.
>
> kvaser_pciefd_remove() is different: its timer_delete() is followed by
> free_irq() and then by the final free_candev(), while the interrupt
> handler can still rearm the timer.  That is the call converted by this
> patch, which also adds timer_shutdown_sync() to
> kvaser_pciefd_teardown_can_ctrls(), the probe-error path that frees the
> CAN devices after free_irq().

Thanks for the explanation.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQSl+MghEFFAdY3pYJLMOmT6rpmt0gUCaoVMXQAKCRDMOmT6rpmt
0qMuAQDyz4+BUCe/00dUZ2oXyb8zFZNenzRj0zqLS3jQYrTKvQEA2ACowyu+IipL
rCZv3Iv8/fu3+KRyk6INBF9BmvhFLQc=
=kCD6
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.