]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvmet-tcp: fix callback lock for TLS handshake
authorMaurizio Lombardi <mlombard@redhat.com>
Fri, 4 Jul 2025 14:44:54 +0000 (16:44 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 15 Jul 2025 07:49:13 +0000 (09:49 +0200)
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: 675b453e0241 ("nvmet-tcp: enable TLS handshake upcall")
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/tcp.c

index c6603bd9c95edfee953cd0aa3a961e79940a24d5..c58d2caef70ad02fc183a15dd880778fd399b078 100644 (file)
@@ -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;