nvmet-tcp: check return value of nvmet_tcp_set_queue_sock
Subsystems (2)
PATCH v2 1/1 nvmet-tcp: check return value of nvmet_tcp_set_queue_sock
From: Geliang Tang <[email protected]>
The return value of nvmet_tcp_set_queue_sock() is currently ignored in nvmet_tcp_tls_handshake_done(). If it fails (e.g., due to the socket not being in TCP_ESTABLISHED state), the socket callbacks will not be properly set, leading to queue and socket leakage.
Fix this by capturing the return value and calling nvmet_tcp_schedule_release_queue() on failure to ensure proper cleanup.
---
v2:
- add Hannes's reviewed tag.
- drop patch 2 in v1 as Maurizio suggested.
v1:
- https://patchwork.kernel.org/project/linux-nvme/cover/[email protected]/
--- drivers/nvme/target/tcp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/target/tcp.c +3 -2
@@ -1844,10 +1844,11 @@ static void nvmet_tcp_tls_handshake_done(void *data, int status,if (!status) status =nvmet_tcp_tls_key_lookup (queue, peerid); +if (!status) + status =nvmet_tcp_set_queue_sock (queue); +if (status)nvmet_tcp_schedule_release_queue (queue); -else -nvmet_tcp_set_queue_sock (queue);kref_put (&queue->kref, nvmet_tcp_release_queue); }
Signature · 1 line
2.53.0
Quoted 7 lines · Geliang Tang
From: Geliang Tang<[email protected]>
The return value of
nvmet_tcp_set_queue_sock()is currently ignored innvmet_tcp_tls_handshake_done(). If it fails (e.g., due to the socket not being inTCP_ESTABLISHEDstate), the socket callbacks will not be properly set, leading to queue and socket leakage.
Quoted 6 lines
Fix this by capturing the return value and calling
nvmet_tcp_schedule_release_queue()on failure to ensure proper cleanup.Fixes 675b453e0241 ("nvmet-tcp: enable TLS handshake upcall")Reviewed-by Hannes Reinecke<[email protected]>Signed-off-by Geliang Tang<[email protected]>
Looks good.
-ck
Quoted 9 lines · Geliang Tang
From: Geliang Tang <[email protected]>
The return value of
nvmet_tcp_set_queue_sock()is currently ignored innvmet_tcp_tls_handshake_done(). If it fails (e.g., due to the socket not being inTCP_ESTABLISHEDstate), the socket callbacks will not be properly set, leading to queue and socket leakage.Fix this by capturing the return value and calling
nvmet_tcp_schedule_release_queue()on failure to ensure proper cleanup.
Thanks, applied to nvme-7.2.