tipc: fix a potential deadlock
authorYing Xue <ying.xue@windriver.com>
Mon, 20 Oct 2014 06:44:25 +0000 (14:44 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Oct 2014 19:28:15 +0000 (15:28 -0400)
commit7b8613e0a1502b43b3b36c93c66f835c891f63b3
treea2152fd6e1094c6716855e1ae5a4299f1c95a203
parent73829bf6fec70703f10e360676d81d327f21ebf6
tipc: fix a potential deadlock

Locking dependency detected below possible unsafe locking scenario:

           CPU0                          CPU1
T0:  tipc_named_rcv()                tipc_rcv()
T1:  [grab nametble write lock]*     [grab node lock]*
T2:  tipc_update_nametbl()           tipc_node_link_up()
T3:  tipc_nodesub_subscribe()        tipc_nametbl_publish()
T4:  [grab node lock]*               [grab nametble write lock]*

The opposite order of holding nametbl write lock and node lock on
above two different paths may result in a deadlock. If we move the
the updating of the name table after link state named out of node
lock, the reverse order of holding locks will be eliminated, and
as a result, the deadlock risk.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/node.c
net/tipc/node.h
net/tipc/socket.c