Message ID | 20211217022941.27901-1-linma@zju.edu.cn (mailing list archive) |
---|---|
State | Accepted |
Commit | 1ade48d0c27d5da1ccf4b583d8c5fc8b534a3ac8 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v0] ax25: NPD bug when detaching AX25 device | expand |
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Fri, 17 Dec 2021 10:29:41 +0800 you wrote: > The existing cleanup routine implementation is not well synchronized > with the syscall routine. When a device is detaching, below race could > occur. > > static int ax25_sendmsg(...) { > ... > lock_sock() > ax25 = sk_to_ax25(sk); > if (ax25->ax25_dev == NULL) // CHECK > ... > ax25_queue_xmit(skb, ax25->ax25_dev->dev); // USE > ... > } > > [...] Here is the summary with links: - [v0] ax25: NPD bug when detaching AX25 device https://git.kernel.org/netdev/net/c/1ade48d0c27d You are awesome, thank you!
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 2f34bbdde0e8..cfca99e295b8 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -85,8 +85,10 @@ static void ax25_kill_by_device(struct net_device *dev) again: ax25_for_each(s, &ax25_list) { if (s->ax25_dev == ax25_dev) { - s->ax25_dev = NULL; spin_unlock_bh(&ax25_list_lock); + lock_sock(s->sk); + s->ax25_dev = NULL; + release_sock(s->sk); ax25_disconnect(s, ENETUNREACH); spin_lock_bh(&ax25_list_lock);