Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

can: j1939: make j1939_session_activate() fail if device is no longer registered

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 <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>

authored by

Tetsuo Handa and committed by
Marc Kleine-Budde
5d560223 885bebac

+2
+2
net/can/j1939/transport.c
··· 1567 1567 if (active) { 1568 1568 j1939_session_put(active); 1569 1569 ret = -EAGAIN; 1570 + } else if (priv->ndev->reg_state != NETREG_REGISTERED) { 1571 + ret = -ENODEV; 1570 1572 } else { 1571 1573 WARN_ON_ONCE(session->state != J1939_SESSION_NEW); 1572 1574 list_add_tail(&session->active_session_list_entry,