• Ying Xue's avatar
    tipc: fix deadlock during socket release · 84602761
    Ying Xue authored
    A deadlock might occur if name table is withdrawn in socket release
    routine, and while packets are still being received from bearer.
    
           CPU0                       CPU1
    T0:   recv_msg()               release()
    T1:   tipc_recv_msg()          tipc_withdraw()
    T2:   [grab node lock]         [grab port lock]
    T3:   tipc_link_wakeup_ports() tipc_nametbl_withdraw()
    T4:   [grab port lock]*        named_cluster_distribute()
    T5:   wakeupdispatch()         tipc_link_send()
    T6:                            [grab node lock]*
    
    The opposite order of holding port lock and node lock on above two
    different paths may result in a deadlock. If socket lock instead of
    port lock is used to protect port instance in tipc_withdraw(), the
    reverse order of holding port lock and node lock will be eliminated,
    as a result, the deadlock is killed as well.
    Reported-by: default avatarLars Everbrand <lars.everbrand@ericsson.com>
    Reviewed-by: default avatarErik Hugne <erik.hugne@ericsson.com>
    Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    84602761
port.c 25.1 KB