mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:19:34 +02:00
net/smc: hash socket only after full initialisation in smc_sk_init()
smc_sk_init() calls sk->sk_prot->hash(sk) before several fields are
fully initialised: clcsock_release_lock, the saved clcsk_* callbacks,
use_fallback/fallback_rsn, and conn.close_work. Once hash() returns the
socket is visible to concurrent hash walkers, which can then observe
uninitialised state.
Move hash(sk) to the end of smc_sk_init() so the socket is published
only after it is fully constructed.
Fixes: d0e35656d8 ("net/smc: refactoring initialization of smc sock")
Reviewed-by: Hidayath Khan <hidayath@linux.ibm.com>
Reviewed-by: Sidraya Jayagond <sidraya@linux.ibm.com>
Signed-off-by: Mahanta Jambigi <mjambigi@linux.ibm.com>
Link: https://patch.msgid.link/20260813074315.554926-1-mjambigi@linux.ibm.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
cb7643b78d
commit
8acf691d80
+1
-1
@@ -409,13 +409,13 @@ void smc_sk_init(struct net *net, struct sock *sk, int protocol)
|
||||
"sk_lock-AF_SMC", &smc_key);
|
||||
spin_lock_init(&smc->accept_q_lock);
|
||||
spin_lock_init(&smc->conn.send_lock);
|
||||
sk->sk_prot->hash(sk);
|
||||
mutex_init(&smc->clcsock_release_lock);
|
||||
smc_init_saved_callbacks(smc);
|
||||
smc->limit_smc_hs = net->smc.limit_smc_hs;
|
||||
smc->use_fallback = false; /* assume rdma capability first */
|
||||
smc->fallback_rsn = 0;
|
||||
smc_close_init(smc);
|
||||
sk->sk_prot->hash(sk);
|
||||
}
|
||||
|
||||
static struct sock *smc_sock_alloc(struct net *net, struct socket *sock,
|
||||
|
||||
Reference in New Issue
Block a user