Commit 0523c6cc authored by Maurizio Lombardi's avatar Maurizio Lombardi Committed by Christoph Hellwig
Browse files

nvmet-tcp: fix callback lock for TLS handshake



When restoring the default socket callbacks during a TLS handshake, we
need to acquire a write lock on sk_callback_lock.  Previously, a read
lock was used, which is insufficient for modifying sk_user_data and
sk_data_ready.

Fixes: 675b453e ("nvmet-tcp: enable TLS handshake upcall")
Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 71257925
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1928,10 +1928,10 @@ static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
		struct sock *sk = queue->sock->sk;

		/* Restore the default callbacks before starting upcall */
		read_lock_bh(&sk->sk_callback_lock);
		write_lock_bh(&sk->sk_callback_lock);
		sk->sk_user_data = NULL;
		sk->sk_data_ready = port->data_ready;
		read_unlock_bh(&sk->sk_callback_lock);
		write_unlock_bh(&sk->sk_callback_lock);
		if (!nvmet_tcp_try_peek_pdu(queue)) {
			if (!nvmet_tcp_tls_handshake(queue))
				return;