tipc: use lock_sock() in tipc_sk_reinit()
lock_sock() must be used in process context to be race-free with
other lock_sock() callers, for example, tipc_release(). Otherwise
using the spinlock directly can't serialize a parallel tipc_release().
As it is blocking, we have to hold the sock refcnt before
rhashtable_walk_stop() and release it after rhashtable_walk_start().
Fixes: 07f6c4bc04
("tipc: convert tipc reference table to use generic rhashtable")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Ying Xue <ying.xue@windriver.com>
Cc: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d3e8869ec8
commit
15ef70e286
|
@ -2724,11 +2724,15 @@ void tipc_sk_reinit(struct net *net)
|
|||
rhashtable_walk_start(&iter);
|
||||
|
||||
while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) {
|
||||
spin_lock_bh(&tsk->sk.sk_lock.slock);
|
||||
sock_hold(&tsk->sk);
|
||||
rhashtable_walk_stop(&iter);
|
||||
lock_sock(&tsk->sk);
|
||||
msg = &tsk->phdr;
|
||||
msg_set_prevnode(msg, tipc_own_addr(net));
|
||||
msg_set_orignode(msg, tipc_own_addr(net));
|
||||
spin_unlock_bh(&tsk->sk.sk_lock.slock);
|
||||
release_sock(&tsk->sk);
|
||||
rhashtable_walk_start(&iter);
|
||||
sock_put(&tsk->sk);
|
||||
}
|
||||
|
||||
rhashtable_walk_stop(&iter);
|
||||
|
|
Loading…
Reference in New Issue