nvmet-auth: always free derived key data
Subsystems (3)
PATCH 1/1 nvmet-auth: always free derived key data
After calling nvme_auth_derive_tls_psk() we need to free the resulting psk data, as either TLS is disable (and we don't need the data anyway) or the psk data is copied into the resulting key (and can be free, too).
Fixes fa2e0f8bbc68 ("nvmet-tcp: support secure channel concatenation")
Reported-by Yi Zhang <[email protected]>
Suggested-by Maurizio Lombardi <[email protected]>
Signed-off-by Hannes Reinecke <[email protected]>
--- drivers/nvme/target/auth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/nvme/target/auth.c +1 -2
@@ -656,13 +656,12 @@ void nvmet_auth_insert_psk(struct nvmet_sq *sq)pr_warn ("%s: ctrl %d qid %d failed to refresh key, error %ld\n" , __func__, sq->ctrl->cntlid, sq->qid,PTR_ERR (tls_key)); tls_key = NULL; - kfree_sensitive(tls_psk); }if (sq->ctrl->tls_key)key_put (sq->ctrl->tls_key); sq->ctrl->tls_key = tls_key;#endif - +kfree_sensitive (tls_psk); out_free_digest:kfree_sensitive (digest); out_free_psk:
Signature · 1 line
2.35.3
Reviewed-by Sagi Grimberg <[email protected]>
Quoted 9 lines · Hannes Reinecke
After calling
nvme_auth_derive_tls_psk()we need to free the resulting psk data, as either TLS is disable (and we don't need the data anyway) or the psk data is copied into the resulting key (and can be free, too).Fixes fa2e0f8bbc68 ("nvmet-tcp: support secure channel concatenation")Reported-by Yi Zhang <[email protected]>Suggested-by Maurizio Lombardi <[email protected]>Signed-off-by Hannes Reinecke <[email protected]>
Thanks for the fix:
Tested-by Yi Zhang <[email protected]>
Quoted 26 lines
--- drivers/nvme/target/auth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/nvme/target/auth.c +1
-3@@ -656,13 +656,12 @@ void nvmet_auth_insert_psk(struct nvmet_sq *sq)pr_warn ("%s: ctrl %d qid %d failed to refresh key, error %ld\n" , __func__, sq->ctrl->cntlid, sq->qid,PTR_ERR (tls_key)); tls_key = NULL; -kfree_sensitive (tls_psk); }if (sq->ctrl->tls_key)key_put (sq->ctrl->tls_key); sq->ctrl->tls_key = tls_key;#endif - +kfree_sensitive (tls_psk); out_free_digest:kfree_sensitive (digest); out_free_psk: --2.35.3
Signature · 2 lines
Best Regards, Yi Zhang
Christoph Hellwig
maintainerThanks,
added to nvme-6.15.