Skip to contentSkip to conversation

nvmet-tcp: always initialize tls_handshake_tmo_work

PATCH In review Hannes Reinecke 5 participants 5 messages Oct 20, 2023 – Nov 20, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 nvmet-tcp: always initialize tls_handshake_tmo_work

The TLS handshake timeout work item should always be initialized to avoid a crash when cancelling the workqueue.

Fixes 675b453e0241 ("nvmet-tcp: enable TLS handshake upcall")
---
 drivers/nvme/target/tcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/tcp.c +3 -1
index 4336fe048e43..b3c1cc6690f6 100644
@@ -1856,6 +1856,8 @@ static int nvmet_tcp_tls_handshake(struct nvmet_tcp_queue *queue)
 	}
 	return ret;
 }
+#else
+static void nvmet_tcp_tls_handshake_timeout(struct work_struct *w) {}
 #endif
 
 static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
@@ -1913,9 +1915,9 @@ static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
 	list_add_tail(&queue->queue_list, &nvmet_tcp_queue_list);
 	mutex_unlock(&nvmet_tcp_queue_mutex);
 
-#ifdef CONFIG_NVME_TARGET_TCP_TLS
 	INIT_DELAYED_WORK(&queue->tls_handshake_tmo_work,
 			  nvmet_tcp_tls_handshake_timeout);
+#ifdef CONFIG_NVME_TARGET_TCP_TLS
 	if (queue->state == NVMET_TCP_Q_TLS_HANDSHAKE) {
 		struct sock *sk = queue->sock->sk;
 
Signature · 1 line
2.35.3
Tested-by on v3 1/1
#1 lore raw

Confirmed below issue was fixed by this patch.
https://lore.kernel.org/linux-nvme/CAHj4cs_Lprbh1zWsJ2yT6+qhNoqjrGDrBgx+XOYvU9SLpmLTtw@mail.gmail.com/

Quoted 39 lines · Hannes Reinecke

The TLS handshake timeout work item should always be initialized to avoid a crash when cancelling the workqueue.

Fixes 675b453e0241 ("nvmet-tcp: enable TLS handshake upcall")
---
 drivers/nvme/target/tcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/tcp.c +3 -2
index 4336fe048e43..b3c1cc6690f6 100644
@@ -1856,6 +1856,8 @@ static int nvmet_tcp_tls_handshake(struct nvmet_tcp_queue *queue)
        }
        return ret;
 }
+#else
+static void nvmet_tcp_tls_handshake_timeout(struct work_struct *w) {}
 #endif
 
 static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
@@ -1913,9 +1915,9 @@ static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
        list_add_tail(&queue->queue_list, &nvmet_tcp_queue_list);
        mutex_unlock(&nvmet_tcp_queue_mutex);
 
-#ifdef CONFIG_NVME_TARGET_TCP_TLS
        INIT_DELAYED_WORK(&queue->tls_handshake_tmo_work,
                          nvmet_tcp_tls_handshake_timeout);
+#ifdef CONFIG_NVME_TARGET_TCP_TLS
        if (queue->state == NVMET_TCP_Q_TLS_HANDSHAKE) {
                struct sock *sk = queue->sock->sk;
 
--

2.35.3

Signature · 2 lines
Best Regards,
  Yi Zhang
Tested-by on v3 1/1
#2 lore raw
In reply to Hannes Reinecke
Quoted 6 lines · Hannes Reinecke

The TLS handshake timeout work item should always be initialized to avoid a crash when cancelling the workqueue.

Fixes 675b453e0241 ("nvmet-tcp: enable TLS handshake upcall")

I also confirmed that this patch fixes blktests nvme test group failures observed with tcp transport.