Skip to content

Commit ba6f0d1

Browse files
Tetsuo Handagregkh
authored andcommitted
can: j1939: make j1939_session_activate() fail if device is no longer registered
[ Upstream commit 5d56022 ] syzbot is still reporting unregister_netdevice: waiting for vcan0 to become free. Usage count = 2 even after commit 93a27b5 ("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 <syzbot+881d65229ca4f9ae8c84@syzkaller.appspotmail.com> Closes: https://syzkaller.appspot.com/bug?extid=881d65229ca4f9ae8c84 Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Acked-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://patch.msgid.link/b9653191-d479-4c8b-8536-1326d028db5c@I-love.SAKURA.ne.jp Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 47206d7 commit ba6f0d1

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

net/can/j1939/transport.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,8 @@ int j1939_session_activate(struct j1939_session *session)
15711571
if (active) {
15721572
j1939_session_put(active);
15731573
ret = -EAGAIN;
1574+
} else if (priv->ndev->reg_state != NETREG_REGISTERED) {
1575+
ret = -ENODEV;
15741576
} else {
15751577
WARN_ON_ONCE(session->state != J1939_SESSION_NEW);
15761578
list_add_tail(&session->active_session_list_entry,

0 commit comments

Comments
 (0)