Re: [PATCH] net/sctp: fix race condition in sctp_destroy_sock

From: Marcelo Ricardo Leitner
Date: Tue Apr 13 2021 - 11:20:56 EST


On Tue, Apr 13, 2021 at 12:31:53PM +0300, Or Cohen wrote:
> +++ b/net/sctp/socket.c
> @@ -1520,11 +1520,9 @@ static void sctp_close(struct sock *sk, long timeout)
>
> /* Supposedly, no process has access to the socket, but
> * the net layers still may.
> - * Also, sctp_destroy_sock() needs to be called with addr_wq_lock
> - * held and that should be grabbed before socket lock.
> */

Please also update the following comment in sctp_init_sock():
/* Nothing can fail after this block, otherwise
* sctp_destroy_sock() will be called without addr_wq_lock held
*/

Other than this, LGTM. Thanks.

Marcelo