From: Karl Mehltretter <kmehltretter@gmail.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
Robin van der Gracht <robin@protonic.nl>,
Oleksij Rempel <o.rempel@pengutronix.de>,
kernel@pengutronix.de, Oliver Hartkopp <socketcan@hartkopp.net>,
Marc Kleine-Budde <mkl@pengutronix.de>,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3.2] can: j1939: fix j1939_ecu refcount leak
Date: Tue, 27 Oct 2026 04:31:04 +0100 [thread overview]
Message-ID: <20261027033104.76618-1-kmehltretter@gmail.com> (raw)
In-Reply-To: <3958917c-1484-41e8-8d62-99575edbf980@I-love.SAKURA.ne.jp>
> list_for_each_entry(ecu, &priv->ecus, list) {
> - if (ecu->name == name)
> + if (ecu->name == name && j1939_ecu_valid(ecu))
> return ecu;
This also hides a live, named ECU from j1939_local_ecu_put() during
unregister. The netdev core sets reg_state to NETREG_UNREGISTERING before
issuing NETDEV_UNREGISTER, so j1939_ecu_valid() is false when a bound
socket reaches this cleanup path:
j1939_netdev_notifier()
j1939_sk_netdev_event_unregister()
j1939_local_ecu_put()
j1939_ecu_find_by_name_locked()
The lookup then returns NULL. j1939_local_ecu_put() warns and returns
without dropping the socket's ECU reference. That keeps the ECU's netdev
and j1939_priv references alive, preventing netdev_wait_allrefs_any()
from completing.
This is based on source review with AI assistance. I have not reproduced
the unregister hang at runtime.
Could teardown use a lookup that permits NETREG_UNREGISTERING and a dead
rx_kref, while retaining the nonzero ecu->kref check? The registration
and receive-lifetime restrictions are needed when acquiring new users,
but cleanup must still find the ECU whose reference it owns.
The ecu->kref check remains necessary because zero-reference entries stay on
the list until the RCU callback removes them.
Thanks,
Karl
next prev parent reply other threads:[~2026-10-27 3:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 14:54 [PATCH v3.1] " Tetsuo Handa
2026-10-27 0:22 ` [PATCH v3.2] " Tetsuo Handa
2026-10-27 3:31 ` Karl Mehltretter [this message]
2026-10-27 14:35 ` Tetsuo Handa
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=20261027033104.76618-1-kmehltretter@gmail.com \
--to=kmehltretter@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=robin@protonic.nl \
--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
all inboxes | Powered by JetHome®