stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmet-auth: assign dh_key to NULL after kfree_sensitive
@ 2024-09-16 17:41 Vitaliy Shevtsov
  2024-09-16 20:44 ` Hannes Reinecke
  2024-09-17  6:12 ` Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Vitaliy Shevtsov @ 2024-09-16 17:41 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Vitaliy Shevtsov, Hannes Reinecke, Christoph Hellwig,
	Sagi Grimberg, Chaitanya Kulkarni, Jens Axboe, linux-nvme,
	linux-kernel

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@vger.kernel.org
Signed-off-by: Vitaliy Shevtsov <v.shevtsov@maxima.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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvmet-auth: assign dh_key to NULL after kfree_sensitive
  2024-09-16 17:41 [PATCH] nvmet-auth: assign dh_key to NULL after kfree_sensitive Vitaliy Shevtsov
@ 2024-09-16 20:44 ` Hannes Reinecke
  2024-09-17  6:12 ` Christoph Hellwig
  1 sibling, 0 replies; 5+ messages in thread
From: Hannes Reinecke @ 2024-09-16 20:44 UTC (permalink / raw)
  To: Vitaliy Shevtsov, stable, Greg Kroah-Hartman
  Cc: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Jens Axboe,
	linux-nvme, linux-kernel

On 9/16/24 19:41, Vitaliy Shevtsov wrote:
> 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@vger.kernel.org
> Signed-off-by: Vitaliy Shevtsov <v.shevtsov@maxima.ru>
> ---
>   drivers/nvme/target/auth.c | 1 +
>   1 file changed, 1 insertion(+)
> 
Now that is obviously correct.

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvmet-auth: assign dh_key to NULL after kfree_sensitive
  2024-09-16 17:41 [PATCH] nvmet-auth: assign dh_key to NULL after kfree_sensitive Vitaliy Shevtsov
  2024-09-16 20:44 ` Hannes Reinecke
@ 2024-09-17  6:12 ` Christoph Hellwig
  2024-10-25 13:01   ` Fedor Pchelkin
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2024-09-17  6:12 UTC (permalink / raw)
  To: Vitaliy Shevtsov
  Cc: stable, Greg Kroah-Hartman, Hannes Reinecke, Christoph Hellwig,
	Sagi Grimberg, Chaitanya Kulkarni, Jens Axboe, linux-nvme,
	linux-kernel


Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvmet-auth: assign dh_key to NULL after kfree_sensitive
  2024-09-17  6:12 ` Christoph Hellwig
@ 2024-10-25 13:01   ` Fedor Pchelkin
  2024-10-25 14:51     ` Keith Busch
  0 siblings, 1 reply; 5+ messages in thread
From: Fedor Pchelkin @ 2024-10-25 13:01 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: stable, Greg Kroah-Hartman, Hannes Reinecke, Christoph Hellwig,
	Keith Busch, Sagi Grimberg, Chaitanya Kulkarni, Jens Axboe,
	linux-nvme, linux-kernel, Vitaliy Shevtsov

On 2024-09-17 Christoph Hellwig wrote:
> Looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

I suspect the patch has been lost - it's still missing on nvme-6.12 or
nvme-6.13 at git.infradead.org/nvme.git.

--
Thanks,
Fedor

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nvmet-auth: assign dh_key to NULL after kfree_sensitive
  2024-10-25 13:01   ` Fedor Pchelkin
@ 2024-10-25 14:51     ` Keith Busch
  0 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2024-10-25 14:51 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Christoph Hellwig, stable, Greg Kroah-Hartman, Hannes Reinecke,
	Sagi Grimberg, Chaitanya Kulkarni, Jens Axboe, linux-nvme,
	linux-kernel, Vitaliy Shevtsov

On Fri, Oct 25, 2024 at 04:01:18PM +0300, Fedor Pchelkin wrote:
> I suspect the patch has been lost - it's still missing on nvme-6.12 or
> nvme-6.13 at git.infradead.org/nvme.git.

Thanks for the ping. Patch applied to nvme-6.12.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-25 14:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 17:41 [PATCH] nvmet-auth: assign dh_key to NULL after kfree_sensitive Vitaliy Shevtsov
2024-09-16 20:44 ` Hannes Reinecke
2024-09-17  6:12 ` Christoph Hellwig
2024-10-25 13:01   ` Fedor Pchelkin
2024-10-25 14:51     ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).