Skip to content

Commit de41cbc

Browse files
metze-sambarleon
authored andcommitted
RDMA/rxe: let rxe_reclassify_recv_socket() call sk_owner_put()
On kernels build with CONFIG_PROVE_LOCKING, CONFIG_MODULES and CONFIG_DEBUG_LOCK_ALLOC 'rmmod rdma_rxe' is no longer possible. For the global recv sockets rxe_net_exit() is where we call rxe_release_udp_tunnel-> udp_tunnel_sock_release(), which means the sockets are destroyed before 'rmmod rdma_rxe' finishes, so there's no need to protect against rxe_recv_slock_key and rxe_recv_sk_key disappearing while the sockets are still alive. Fixes: 80a85a7 ("RDMA/rxe: reclassify sockets in order to avoid false positives from lockdep") Cc: Zhu Yanjun <zyjzyj2000@gmail.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Leon Romanovsky <leon@kernel.org> Cc: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> Cc: linux-rdma@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-cifs@vger.kernel.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Link: https://patch.msgid.link/20251219140408.2300163-1-metze@samba.org Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 145a417 commit de41cbc

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

drivers/infiniband/sw/rxe/rxe_net.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,39 @@ static inline void rxe_reclassify_recv_socket(struct socket *sock)
6464
break;
6565
default:
6666
WARN_ON_ONCE(1);
67+
return;
6768
}
69+
/*
70+
* sock_lock_init_class_and_name() calls
71+
* sk_owner_set(sk, THIS_MODULE); in order
72+
* to make sure the referenced global
73+
* variables rxe_recv_slock_key and
74+
* rxe_recv_sk_key are not removed
75+
* before the socket is closed.
76+
*
77+
* However this prevents rxe_net_exit()
78+
* from being called and 'rmmod rdma_rxe'
79+
* is refused because of the references.
80+
*
81+
* For the global sockets in recv_sockets,
82+
* we are sure that rxe_net_exit() will call
83+
* rxe_release_udp_tunnel -> udp_tunnel_sock_release.
84+
*
85+
* So we don't need the additional reference to
86+
* our own (THIS_MODULE).
87+
*/
88+
sk_owner_put(sk);
89+
/*
90+
* We also call sk_owner_clear() otherwise
91+
* sk_owner_put(sk) in sk_prot_free will
92+
* fail, which is called via
93+
* sk_free -> __sk_free -> sk_destruct
94+
* and sk_destruct calls __sk_destruct
95+
* directly or via call_rcu()
96+
* so sk_prot_free() might be called
97+
* after rxe_net_exit().
98+
*/
99+
sk_owner_clear(sk);
68100
#endif /* CONFIG_DEBUG_LOCK_ALLOC */
69101
}
70102

0 commit comments

Comments
 (0)