Subject: BUG: sleeping function called from invalid context at net/core/sock.c:LINE (3)

From: syzbot <[email-masked]>
Date: Mon, 19 Feb 2018 06:14:00 -0800

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger  
crash:

Reported-and-tested-by:  
[email-masked]

Note: the tag will also help syzbot to understand when the bug is fixed.

Tested on net-next commit
1ec010e705934c8acbe7dbf31afc81e60e3d828b (Fri Feb 16 10:03:07 2018 +0000)
tun: export flags, uid, gid, queue information over netlink

compiler: gcc (GCC) 7.1.1 20170620
Patch is attached.
Kernel config is attached.

---
There is no WARRANTY for the result, to the extent permitted by applicable  
law.
Except when otherwise stated in writing syzbot provides the result "AS IS"
without warranty of any kind, either expressed or implied, but not limited  
to,
the implied warranties of merchantability and fittness for a particular  
purpose.
The entire risk as to the quality of the result is with you. Should the  
result
prove defective, you assume the cost of all necessary servicing, repair or
correction.
--- a/net/tipc/topsrv.c
+++ b/net/tipc/topsrv.c
@@ -693,9 +693,9 @@ void tipc_topsrv_stop(struct net *net)
        }
        __module_get(lsock->ops->owner);
        __module_get(lsock->sk->sk_prot_creator->owner);
-       sock_release(lsock);
        srv->listener = NULL;
        spin_unlock_bh(&srv->idr_lock);
+       sock_release(lsock);
        tipc_topsrv_work_stop(srv);
        idr_destroy(&srv->conn_idr);
        kfree(srv);