Skip to content

Commit 52024cd

Browse files
mkjkuba-moo
authored andcommitted
net: mctp: Set SOCK_RCU_FREE
Bind lookup runs under RCU, so ensure that a socket doesn't go away in the middle of a lookup. Fixes: 833ef3b ("mctp: Populate socket implementation") Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250410-mctp-rcu-sock-v1-1-872de9fdc877@codeconstruct.com.au Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f3fdd4f commit 52024cd

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

net/mctp/af_mctp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ static int mctp_sk_hash(struct sock *sk)
630630
{
631631
struct net *net = sock_net(sk);
632632

633+
/* Bind lookup runs under RCU, remain live during that. */
634+
sock_set_flag(sk, SOCK_RCU_FREE);
635+
633636
mutex_lock(&net->mctp.bind_lock);
634637
sk_add_node_rcu(sk, &net->mctp.binds);
635638
mutex_unlock(&net->mctp.bind_lock);

0 commit comments

Comments
 (0)