Skip to content

Commit

Permalink
net: mctp: Set SOCK_RCU_FREE
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Matt Johnston authored and Jakub Kicinski committed Apr 12, 2025
1 parent f3fdd4f commit 52024cd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/mctp/af_mctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ static int mctp_sk_hash(struct sock *sk)
{
struct net *net = sock_net(sk);

/* Bind lookup runs under RCU, remain live during that. */
sock_set_flag(sk, SOCK_RCU_FREE);

mutex_lock(&net->mctp.bind_lock);
sk_add_node_rcu(sk, &net->mctp.binds);
mutex_unlock(&net->mctp.bind_lock);
Expand Down

0 comments on commit 52024cd

Please sign in to comment.