[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240916174139.1182-1-v.shevtsov@maxima.ru>
Date: Mon, 16 Sep 2024 22:41:37 +0500
From: Vitaliy Shevtsov <v.shevtsov@...ima.ru>
To: <stable@...r.kernel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC: Vitaliy Shevtsov <v.shevtsov@...ima.ru>, Hannes Reinecke <hare@...e.de>,
Christoph Hellwig <hch@....de>, Sagi Grimberg <sagi@...mberg.me>, Chaitanya
Kulkarni <kch@...dia.com>, Jens Axboe <axboe@...nel.dk>,
<linux-nvme@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] 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: 7a277c37d352 ("nvmet-auth: Diffie-Hellman key exchange support")
Cc: stable@...r.kernel.org
Signed-off-by: Vitaliy Shevtsov <v.shevtsov@...ima.ru>
---
drivers/nvme/target/auth.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c
index e900525b7866..7bca64de4a2f 100644
--- a/drivers/nvme/target/auth.c
+++ b/drivers/nvme/target/auth.c
@@ -101,6 +101,7 @@ int nvmet_setup_dhgroup(struct nvmet_ctrl *ctrl, u8 dhgroup_id)
pr_debug("%s: ctrl %d failed to generate private key, err %d\n",
__func__, ctrl->cntlid, ret);
kfree_sensitive(ctrl->dh_key);
+ ctrl->dh_key = NULL;
return ret;
}
ctrl->dh_keysize = crypto_kpp_maxsize(ctrl->dh_tfm);
--
2.46.1
Powered by blists - more mailing lists