From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796139878; b=m4xQ881WWK+34p0rJQV0ByLQCLLBqI/FfjXjHwJFGo2RDfWMBAHDHF8c3gBaW81J6b0n e4E2UyQliFSVHsM6vEg5dbwjga/dIf0WaKsyEYBUxIqdk3HJOZZbjn3uivll//CSbB2w/ gXVN0YvutQ39CXS1pj3wqYwUwtOBH0N0m42hNAZtY7PSWYfZN17DW8QTwN0CkzkBWunw5 YRmqL2yhRPaSBoQvPHnww8lQY6wXfNfRpvm72Cx25XoJhCX7QYAbAWY1ryVk2i2FOIkij tGCFXlNgfLDoLRfVeUXUp+AOyVqXAEpJa5OCFWpbMk3KFuX0XtROHRfWBUYYmzc+EAQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796139878; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Io4GMb6kC6zsYzpI5BCgmv1xkhT8WTdml7+79kOcFUM=; b=0lCifweMAgFthxx7O4kVOEPEJ1kFwHt5+YjymrPcH3oPp4mCrrPhIq8G1Rq4cOhrFVgm 4zIamQ+QwSc4tRwRlG2QCLIINnPekE7Prw4YgF8FLzq4/qbO7htkFYLL0vv8jE2L6o2dJ FOm6AlpmkLEttNePnYtNK7whmp64YhXo7d4CWQfmd+u/YnZY7gvL8J/sNCOBnRkFa/Mqo J+O1GFe2ZgYPZi8hanR0PlCcry7V1dLv2KWmeBK3qA1KGtZQq8MNk2nW4Hcuk8Wa/JdM9 h0nPfKvaugPk8JJwypGHfDElnsjVk7dqKTVOpE4W7IMA0DxnFNqavRMdoUY3yJTODXw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iBpmkIuy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD3D9606A31A for ; Tue, 1 Dec 2026 15:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iBpmkIuy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03E8D1F00899; Tue, 1 Dec 2026 15:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796139877; bh=Io4GMb6kC6zsYzpI5BCgmv1xkhT8WTdml7+79kOcFUM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=iBpmkIuyExYIMk8xWub9O+vjOy5RPaBdQDeS3qK8oz6Vf5TkM4rMJSr3GL9QPlqSE XO1G3jECdtrToGoKF/UR8HNtHtAZGOtvq5bIap49kdPOENOGEp+e1//4wNUIk363Ey 2e+VuRSjGDqQAOQ4rGJaFgOlA7adCadyAAO1TzW16kc1j7YOYR0kVLyXZlCXLFSOSO bKWUzuoGHyFz9hk6SwPe6XkvQgN7rVeXs7dkgQooKz8NEDJgJWbBJW0INdvJj20H9y RayqBsfDZ44jkzO20LBTylyqSchc1WI/RcylaFoqHBOlY66h9x1D5TwawAQqAcV1CX YJ+5UiR0JMxSQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] can: j1939: fix possibility of UAF on module unload Reply-To: sashiko-reviews@lists.linux.dev To: "Tetsuo Handa" , linux-can@vger.kernel.org Cc: "Marc Kleine-Budde" , "Oliver Hartkopp" , "Vincent Mailhol" , "Oleksij Rempel" In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 15:44:36 +0000 X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] can: j1939: uninterruptible hang in j1939_module_exit() on ECU timer leak It also noticed 1 related pre-existing issue this patch does not introduce: - [High] can: j1939: resource leak via uncancelled ac_timer in j1939_netdev_notify() [1] -- commit 1a795dad5311bf5450a9def8e0e2df926f4b99f7 Author: Tetsuo Handa can: j1939: fix possibility of UAF on module unload This commit defers struct j1939_priv release to a module-local workqueue and waits in j1939_module_exit() for all struct j1939_priv instances and pending release work to finish before unloading the module. > 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; > } > =20 > 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 wait_event() hang forever if a J1939 socket is closed while an ECU address-claim timer (ecu->ac_timer) is pending? When an address-claim frame starts ecu->ac_timer and the last socket closes before the 250ms timer expires, j1939_sk_release() -> j1939_netdev_stop() -> __j1939_rx_release() calls j1939_ecu_unmap_all(priv) and detaches priv from the net_device, without canceling timers on ECUs in priv->ecus that are not yet mapped in priv->ents[]. When ecu->ac_timer fires later, j1939_ecu_timer_handler() -> j1939_ecu_map_locked() calls j1939_ecu_get(ecu) and maps ecu into priv->ents[ecu->addr]. Nothing will ever unmap that ECU again, leaking its reference on struct j1939_priv so j1939_unload_blocker_count never reaches 0 and delete_module() blocks uninterruptibly with module_mutex held. [Severity: High] This problem wasn't introduced by this patch, but the same uncancelled ecu->ac_timer in j1939_netdev_notify() on NETDEV_DOWN [1] also leaks struct j1939_priv and its netdev_hold() reference, hanging both unregister_netdevice() and this wait_event() on module unload: net/can/j1939/main.c:j1939_netdev_notify() { ... case NETDEV_DOWN: j1939_cancel_active_session(priv, NULL); j1939_sk_netdev_event_netdown(priv); j1939_ecu_unmap_all(priv); break; ... } If the interface goes down within 250ms of receiving an address claim, j1939_ecu_unmap_all(priv) leaves the pending ecu->ac_timer running, and j1939_ecu_timer_handler() later maps the ECU back into priv->ents[] after teardown has already finished. [1] https://sashiko.dev/#/bug/linux-22e9fd14-7c3e-4d83-9e1d-af25b216d399 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/aa93c245-399c-499b-= a89e-dddefbf42fcb@I-love.SAKURA.ne.jp?part=3D1