From: sashiko-bot@kernel.org
To: "Tetsuo Handa" <penguin-kernel@I-love.SAKURA.ne.jp>,
linux-can@vger.kernel.org
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH v16 1/5] can: j1939: fix possibility of UAF on j1939_priv upon module unload
Date: Fri, 04 Dec 2026 16:34:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-250199@kernel.org> (raw)
In-Reply-To: <d50ea9d8-b4c6-46b5-8b63-b3e5830575dd@I-love.SAKURA.ne.jp>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] can: j1939: unbounded wait_event() in j1939_module_exit() hangs
rmmod
--
commit acd386211cb084e36e0fd335311a953078fa035b
Author: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
can: j1939: fix possibility of UAF on j1939_priv upon module unload
This commit tracks active struct j1939_priv instances with an atomic
counter, defers __j1939_priv_release() to a module-local workqueue, and
waits in j1939_module_exit() for all instances and release work to
finish before unloading.
> diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
> index d9384cf0e356f..858f9fa1a02ff 100644
> --- a/net/can/j1939/main.c
> +++ b/net/can/j1939/main.c
[ ... ]
> @@ -416,14 +441,28 @@ static __init int j1939_module_init(void)
> fail_sk:
> unregister_netdevice_notifier(&j1939_netdev_notifier);
> fail_notifier:
> + destroy_workqueue(j1939_wq);
> + fail_wq:
> return ret;
> }
>
> static __exit void j1939_module_exit(void)
> {
> +#if defined(MODULE) && defined(CONFIG_MODULE_UNLOAD)
> + /* Wait until all "struct j1939_priv", "struct j1939_ecu" and
> + * "struct j1939_session" are released.
> + */
> + wait_event(j1939_unload_wait, !atomic_read(&j1939_unload_blocker_count));
> +#endif
[Severity: High]
Can this unbounded wait_event() permanently hang rmmod and wedge the
module?
delete_module() transitions the module to MODULE_STATE_GOING before
calling j1939_module_exit(). If a struct j1939_priv reference leaks,
rmmod can_j1939 hangs forever in uninterruptible sleep and later module
loads fail with -EBUSY until reboot.
Such a leak is reachable via j1939_xtp_rx_dat_one(), which calls
j1939_tp_schedule_txtimer(session, 0) without canceling a pending
txtimer. Two back-to-back block-boundary frames before the timer fires
take two j1939_session_get() refs while j1939_tp_txtimer() drops one.
That leaks session->kref and its reference on priv->kref, keeping
j1939_unload_blocker_count non-zero. Even without a leak,
__j1939_rx_release() leaves active RX sessions running when the last
socket detaches, stalling rmmod until they time out and send aborts.
Pinning the module with try_module_get()/module_put() so rmmod returns
-EBUSY while j1939_priv instances exist, or synchronously canceling
active sessions and timers in __j1939_rx_release(), would avoid blocking
indefinitely in module_exit().
--
Sashiko AI review · https://sashiko.dev/#/patchset/02d9f333-d774-4cec-9d12-cb181395fd8a@I-love.SAKURA.ne.jp?part=1
next prev parent reply other threads:[~2026-12-04 16:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 16:03 [PATCH v16 0/5] can: j1939: make module more robust Tetsuo Handa
2026-12-04 16:03 ` [PATCH v16 1/5] can: j1939: fix possibility of UAF on j1939_priv upon module unload Tetsuo Handa
2026-12-04 16:34 ` sashiko-bot [this message]
2026-12-04 16:04 ` [PATCH v16 2/5] can: j1939: fix possibility of UAF on j1939_session " Tetsuo Handa
2026-12-04 16:29 ` sashiko-bot
2026-12-04 16:04 ` [PATCH v16 3/5] can: j1939: fix possibility of UAF on j1939_ecu " Tetsuo Handa
2026-12-04 16:04 ` [PATCH v16 4/5] can: j1939: fix "struct j1939_ecu" refcount leak Tetsuo Handa
2026-12-04 16:23 ` sashiko-bot
2026-12-04 16:05 ` [PATCH v16 5/5] can: j1939: fix possibility of list corruption in __j1939_ecu_release() Tetsuo Handa
2026-12-04 16:23 ` sashiko-bot
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=sashiko-outbox-250199@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=sashiko-reviews@lists.linux.dev \
--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