Re: can/j1939: hung inside rtnl_dellink()

From: Oleksij Rempel
Date: Fri Aug 22 2025 - 06:02:23 EST


Hello Tetsuo,

On Sat, Aug 16, 2025 at 03:51:54PM +0900, Tetsuo Handa wrote:
> Hello.
>
> I made a minimized C reproducer for
>
> unregister_netdevice: waiting for vcan0 to become free. Usage count = 2
>
> problem at https://syzkaller.appspot.com/bug?extid=881d65229ca4f9ae8c84 , and
> obtained some data using debug printk() patch. It seems that the cause is
> net/can/j1939/ does not handle NETDEV_UNREGISTER notification
> while net/can/j1939/ can directly call rtnl_dellink() via sendmsg().

Sorry for long delay and than you for your investigation!

> The minimized C reproducer is shown below.
....

> Therefore, I guess that either
>
> j1939_netdev_notify() is handling NETDEV_UNREGISTER notification
>
> or
>
> rtnl_dellink() can be called via sendmsg() despite the j1939 socket
> are in use
>
> is wrong. How to fix this problem?

I assume the first variant is correct. Can you please test following change:
--- a/net/can/j1939/main.c
+++ b/net/can/j1939/main.c
@@ -370,6 +370,7 @@
goto notify_done;

switch (msg) {
+ case NETDEV_UNREGISTER:
case NETDEV_DOWN:
j1939_cancel_active_session(priv, NULL);
j1939_sk_netdev_event_netdown(priv);

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |