Skip to content

Commit d2f551b

Browse files
Vitaliy Shevtsovkeithbusch
authored andcommitted
nvmet-auth: assign dh_key to NULL after kfree_sensitive
ctrl->dh_key might be used across multiple calls to nvmet_setup_dhgroup() for the same controller. So it's better to nullify it after release on error path in order to avoid double free later in nvmet_destroy_auth(). Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: 7a277c3 ("nvmet-auth: Diffie-Hellman key exchange support") Cc: [email protected] Signed-off-by: Vitaliy Shevtsov <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 42ab37e commit d2f551b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/nvme/target/auth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ int nvmet_setup_dhgroup(struct nvmet_ctrl *ctrl, u8 dhgroup_id)
115115
pr_debug("%s: ctrl %d failed to generate private key, err %d\n",
116116
__func__, ctrl->cntlid, ret);
117117
kfree_sensitive(ctrl->dh_key);
118+
ctrl->dh_key = NULL;
118119
return ret;
119120
}
120121
ctrl->dh_keysize = crypto_kpp_maxsize(ctrl->dh_tfm);

0 commit comments

Comments
 (0)