All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hannes Reinecke" <hare@kernel.org>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH v6 3/9] nvme-auth: switch to use 'struct key'
Date: Mon, 23 Nov 2026 17:32:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-229762@kernel.org> (raw)
In-Reply-To: <20261123-dhchap-keyring-v4-v6-3-5082a49715ab@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] nvme-auth: memory leak of transformed_data in
  nvme_auth_transform_key()
--

commit 4697c9583f14fbc14890cc4dbfaed8c9987d382a
Author: Hannes Reinecke <hare@kernel.org>

nvme-auth: switch to use 'struct key'

This commit switches NVMe DH-HMAC-CHAP key storage and handling from
struct nvme_dhchap_key to struct key using the dhchap key type.

> diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c
> index 308af3d7c7383..158c9cb886c15 100644
> --- a/drivers/nvme/common/auth.c
> +++ b/drivers/nvme/common/auth.c
[ ... ]
> @@ -317,11 +261,13 @@ static int nvme_auth_hash(u8 hmac_id, const u8 *data, size_t data_len, u8 *out)
>  	return -EINVAL;
>  }
>  
> -int nvme_auth_transform_key(const struct nvme_dhchap_key *key, const char *nqn,
> +int nvme_auth_transform_key(struct key *key, const char *nqn,
>  			    u8 **transformed_secret)
>  {
[ ... ]
> +	transformed_len = nvme_auth_hmac_hash_len(key_hash);
> +	transformed_data = kzalloc(transformed_len, GFP_KERNEL);
> +	if (!transformed_data) {
> +		ret = -ENOMEM;
> +		goto out_free_data;
> +	}
> +
> +	ret = nvme_auth_hmac_init(&hmac, key_hash, key_data, key_len);
> +	if (ret)
> +		goto out_free_data;
>  	nvme_auth_hmac_update(&hmac, nqn, strlen(nqn));
>  	nvme_auth_hmac_update(&hmac, "NVMe-over-Fabrics", 17);
> -	nvme_auth_hmac_final(&hmac, key_data);
> -	*transformed_secret = key_data;
> -	return transformed_len;
> +	nvme_auth_hmac_final(&hmac, transformed_data);
> +	*transformed_secret = transformed_data;
> +	ret = transformed_len;
> +out_free_data:
> +	kfree_sensitive(key_data);
> +	return ret;
>  }

[Severity: Medium]
Does this leak transformed_data when nvme_auth_hmac_init() fails and jumps
to out_free_data?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-dhchap-keyring-v4-v6-0-5082a49715ab@kernel.org?part=3


  reply	other threads:[~2026-11-23 17:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 17:10 [PATCH v6 0/9] nvme-auth: switch to use the kernel keyring Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 1/9] nvme-auth: modify nvme_auth_transform_key() to return status Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 2/9] nvme-keyring: add 'dhchap' key type Hannes Reinecke
2026-11-23 17:31   ` sashiko-bot
2026-11-24  7:39     ` Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 3/9] nvme-auth: switch to use 'struct key' Hannes Reinecke
2026-11-23 17:32   ` sashiko-bot [this message]
2026-11-24  7:43     ` Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 4/9] nvme: parse dhchap keys during option parsing Hannes Reinecke
2026-11-23 17:26   ` sashiko-bot
2026-11-24  7:51     ` Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 5/9] nvmet-auth: parse dhchap key from configfs attribute Hannes Reinecke
2026-11-23 17:30   ` sashiko-bot
2026-11-24  7:55     ` Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 6/9] nvme: allow to pass in key description as dhchap secret Hannes Reinecke
2026-11-23 17:32   ` sashiko-bot
2026-11-24  8:31     ` Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 7/9] nvme-auth: wait for authentication to finish when changing keys Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 8/9] nvme-fabrics: allow to pass in keyring by name Hannes Reinecke
2026-11-23 17:30   ` sashiko-bot
2026-11-24  9:21     ` Hannes Reinecke
2026-11-23 17:10 ` [PATCH v6 9/9] nvmet: add configfs attribute 'dhchap_keyring' Hannes Reinecke
2026-11-23 17:33   ` sashiko-bot
2026-11-23 21:21 ` [PATCH v6 0/9] nvme-auth: switch to use the kernel keyring Eric Biggers
2026-11-24 10:30   ` Hannes Reinecke
2026-11-24 20:11     ` Eric Biggers
2026-11-24 20:50       ` Martin Belanger
2026-11-24 21:32         ` Eric Biggers
2026-11-24 22:13           ` Martin Belanger
2026-11-25  7:26             ` Hannes Reinecke
2026-11-25 12:18               ` Martin Belanger
2026-11-25 15:43                 ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-229762@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=hare@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.