Linux CAN drivers development
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Robin van der Gracht <robin@protonic.nl>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	linux-can@vger.kernel.org, lvc-project@linuxtesting.org,
	syzbot+489e907b2a026a6f5fa0@syzkaller.appspotmail.com,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Subject: Re: [PATCH RESEND v4] can: j1939: cancel all pending ECUs on device stop
Date: Fri, 27 Nov 2026 10:40:52 +0100	[thread overview]
Message-ID: <awlQJD0GXoDQQ65m@pengutronix.de> (raw)
In-Reply-To: <20261126082257.491041-1-dmantipov@yandex.ru>

Hi Dmitry,

thank you, and sorry for the long silence.

On Thu, Nov 26, 2026 at 11:22:57AM +0300, Dmitry Antipov wrote:
> +             if (hrtimer_try_to_cancel(&ecu->ac_timer) != -1)
> +                     j1939_ecu_put(ecu);

Unless I am missing something, hrtimer_try_to_cancel() returns 0 for an
inactive timer, so this drops a reference the timer does not hold.

> +     j1939_ecu_cancel_all(priv);
>       kref_put_mutex(&priv->rx_kref, __j1939_rx_release,
>       &j1939_netdev_lock);

As far as I can see, j1939_netdev_stop() runs for every closed bound
socket, not only the last one. So this would also cancel address claims
of other sockets and remote ECUs. And an address claim received after
the cancel can still arm a new timer.

If I read the code right, the leak is the reference that
j1939_ecu_map_locked() takes when the timer fires after
j1939_ecu_unmap_all(). Tetsuo's v15 2/3 stops exactly this, without
cancelling anything:

https://lore.kernel.org/all/f778db47-a217-448e-9dbd-f1860afab00b@I-love.SAKURA.ne.jp/

So I would not take this patch. Could you please test the whole v15
series with your syzbot reproducer and reply there, ideally with a
Tested-by? If v15 does not fix your leak, or I overlooked something,
please let me know.

Regards,
Oleksij

  parent reply	other threads:[~2026-11-27  9:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:22 [PATCH RESEND v4] can: j1939: cancel all pending ECUs on device stop Dmitry Antipov
2026-11-26  8:35 ` sashiko-bot
2026-11-27  9:40 ` Oleksij Rempel [this message]
2026-11-27 11:01   ` Dmitry Antipov
2026-11-27 11:04     ` Marc Kleine-Budde

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=awlQJD0GXoDQQ65m@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=dmantipov@yandex.ru \
    --cc=linux-can@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=mkl@pengutronix.de \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=robin@protonic.nl \
    --cc=socketcan@hartkopp.net \
    --cc=syzbot+489e907b2a026a6f5fa0@syzkaller.appspotmail.com \
    /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