From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Dudu Lu <phx0fer@gmail.com>
Cc: linux-can@vger.kernel.org, robin@protonic.nl
Subject: Re: [PATCH] can: j1939: Use hrtimer_cancel in j1939_cancel_active_session
Date: Mon, 13 Apr 2026 15:01:09 +0200 [thread overview]
Message-ID: <adzpFf63Q4_MY0hm@pengutronix.de> (raw)
In-Reply-To: <20260413084548.69294-1-phx0fer@gmail.com>
Hi Dudu,
On Mon, Apr 13, 2026 at 04:45:48PM +0800, Dudu Lu wrote:
> j1939_cancel_active_session() uses hrtimer_try_to_cancel() for both
> txtimer and rxtimer. When hrtimer_try_to_cancel() returns -1, it means
> the timer callback is currently executing. In this case, the function
> neither cancels the timer nor drops the session reference via
> j1939_session_put(). The session is then deactivated while the timer
> callback may still be running, leading to a potential use-after-free if
> the callback accesses the session after it has been cleaned up.
>
> Replace hrtimer_try_to_cancel() with hrtimer_cancel() which will wait
> for an in-progress callback to complete before returning, ensuring the
> timer is fully stopped before the session is deactivated.
>
> Note: This changes the function to potentially sleep (hrtimer_cancel
> waits for the callback). The function is called with
> active_session_list_lock held (a spinlock), so an alternative approach
> would be to handle the -1 return from hrtimer_try_to_cancel() without
> blocking. However, if the lock can be converted or the cancel moved
> outside the lock, hrtimer_cancel() is the cleaner fix.
Is it real or academical issue? Are there some bug report or exploit?
Best regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2026-04-13 13:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 8:45 [PATCH] can: j1939: Use hrtimer_cancel in j1939_cancel_active_session Dudu Lu
2026-04-13 13:01 ` Oleksij Rempel [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=adzpFf63Q4_MY0hm@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=phx0fer@gmail.com \
--cc=robin@protonic.nl \
/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