From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D7473BFE4B; Thu, 15 Jan 2026 18:01:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768500097; cv=none; b=SKFvOJqVngD8SwjkEP3U/mG6J8rlo402OFQPRKgw4e1E2hmXW/5avkmzqq1h3RWQCiRrD3iuHFx5s+I9k9vMcVAwJCxZjfdROkd0kLa/LPaPVnhI/LgLDgoYO1UQDELs7KSH27Cph75b8XTd05x7rEkcs222ImSeBFjJFvNCsjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768500097; c=relaxed/simple; bh=F+ri6v/9iYlqBh0x0CpJQrY6B+gjzsWfj+twLtRiqBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m7O2sSzb1H6dTTsbYduYKPCPllXLhMdsPwX/n61xZOfZ5KD3qPzHMF1Vc7FRokvyCxfe7SGpY1BLNcAxFIzXnPdW0EJToHzIsAuA13LlmL0nBsc0GOoy1PGxvQUOaat9IKlkSPoF4Nm+PHHH6l5uKq8hseuASmkjSwU3rsL8X2E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tmrTq9Al; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="tmrTq9Al" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 975B9C116D0; Thu, 15 Jan 2026 18:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768500097; bh=F+ri6v/9iYlqBh0x0CpJQrY6B+gjzsWfj+twLtRiqBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmrTq9AlODBhd2k+Uum/BGNiS6JmKrUV/fiImHVUK3o32UVMz6K9rAhCEZlsRhzR6 tdFBSBrMwRc4QT16yrLo8K+33OLsD+cZa2BcllszV1hs3n9bviOrCR7QfJnkwteNp+ Hb0z2HSkSHmjJwfW8rWKjXbFARUtAzCTqwpGBaXw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot , Tetsuo Handa , Oleksij Rempel , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.10 449/451] can: j1939: make j1939_session_activate() fail if device is no longer registered Date: Thu, 15 Jan 2026 17:50:50 +0100 Message-ID: <20260115164247.190787423@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164230.864985076@linuxfoundation.org> References: <20260115164230.864985076@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa [ Upstream commit 5d5602236f5db19e8b337a2cd87a90ace5ea776d ] syzbot is still reporting unregister_netdevice: waiting for vcan0 to become free. Usage count = 2 even after commit 93a27b5891b8 ("can: j1939: add missing calls in NETDEV_UNREGISTER notification handler") was added. A debug printk() patch found that j1939_session_activate() can succeed even after j1939_cancel_active_session() from j1939_netdev_notify(NETDEV_UNREGISTER) has completed. Since j1939_cancel_active_session() is processed with the session list lock held, checking ndev->reg_state in j1939_session_activate() with the session list lock held can reliably close the race window. Reported-by: syzbot Closes: https://syzkaller.appspot.com/bug?extid=881d65229ca4f9ae8c84 Signed-off-by: Tetsuo Handa Acked-by: Oleksij Rempel Link: https://patch.msgid.link/b9653191-d479-4c8b-8536-1326d028db5c@I-love.SAKURA.ne.jp Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- net/can/j1939/transport.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c index c433b49f8715c..25e4cdf2df22c 100644 --- a/net/can/j1939/transport.c +++ b/net/can/j1939/transport.c @@ -1555,6 +1555,8 @@ int j1939_session_activate(struct j1939_session *session) if (active) { j1939_session_put(active); ret = -EAGAIN; + } else if (priv->ndev->reg_state != NETREG_REGISTERED) { + ret = -ENODEV; } else { WARN_ON_ONCE(session->state != J1939_SESSION_NEW); list_add_tail(&session->active_session_list_entry, -- 2.51.0