]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvmet-tcp: Don't clear tls_key when freeing sq
authorAlistair Francis <alistair.francis@wdc.com>
Fri, 17 Apr 2026 00:48:09 +0000 (10:48 +1000)
committerKeith Busch <kbusch@kernel.org>
Wed, 22 Apr 2026 17:07:30 +0000 (10:07 -0700)
Curently after the host sends a REPLACETLSPSK we free the TLS keys as
part of calling nvmet_auth_sq_free() on success. This means when the
host sends a follow up REPLACETLSPSK we return CONCAT_MISMATCH as the
check for !nvmet_queue_tls_keyid(req->sq) fails.

A previous attempt to fix this involed not calling nvmet_auth_sq_free()
on successful connections, but that results in memory leaks. Instead we
should not clear `tls_key` in nvmet_auth_sq_free(), as that was
incorrectly wiping the tls keys which are used for the session.

This patch ensures we correctly free the ephemeral session key on
connection, yet we don't free the TLS key unless closing the connection.

Reviewed-by: Chris Leech <cleech@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/auth.c

index b34610e2f19d4dae6588c65a0712a55785f6abe1..723b6d5604c1a08193eef402d8abc1e063f92c7c 100644 (file)
@@ -229,9 +229,6 @@ out_unlock:
 void nvmet_auth_sq_free(struct nvmet_sq *sq)
 {
        cancel_delayed_work(&sq->auth_expired_work);
-#ifdef CONFIG_NVME_TARGET_TCP_TLS
-       sq->tls_key = NULL;
-#endif
        kfree(sq->dhchap_c1);
        sq->dhchap_c1 = NULL;
        kfree(sq->dhchap_c2);