mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Sreeraj S Kurup <sreekuttan2156239@gmail.com>,
	hch@lst.de, sagi@grimberg.me, kch@nvidia.com
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvmet: use appropriate types for authentication payload lengths
Date: Tue, 3 Nov 2026 08:36:16 +0100	[thread overview]
Message-ID: <5deeca7b-8891-42b4-bcff-e8cc566409bb@suse.de> (raw)
In-Reply-To: <20261031075932.4345-1-sreekuttan2156239@gmail.com>

On 10/31/26 8:59 AM, Sreeraj S Kurup wrote:
> The authentication payload length is obtained as a u32 value from the
> NVMe command, but nvmet_auth_challenge() and nvmet_auth_success1()
> accept it as a signed int.
> 
> Use u32 for the payload length parameters in both functions to keep
> their types consistent with the value returned by
> nvmet_auth_receive_data_len() and avoid an unnecessary conversion
> from unsigned to signed.
> 
> Also, use size_t for data_size in nvmet_auth_challenge(), since the
> calculation includes sizeof(), which returns size_t. This avoids
> implicitly narrowing the calculated payload size to int.
> 
> These changes make the payload length handling consistent with the
> underlying types and avoid potential signedness and narrowing issues.
> 
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
> ---
>   drivers/nvme/target/fabrics-cmd-auth.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/fabrics-cmd-auth.c
> index 70136f6c22e8..99caad6fb87f 100644
> --- a/drivers/nvme/target/fabrics-cmd-auth.c
> +++ b/drivers/nvme/target/fabrics-cmd-auth.c
> @@ -448,13 +448,13 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
>   	nvmet_req_complete(req, status);
>   }
>   
> -static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al)
> +static int nvmet_auth_challenge(struct nvmet_req *req, void *d, u32 al)
>   {
>   	struct nvmf_auth_dhchap_challenge_data *data = d;
>   	struct nvmet_ctrl *ctrl = req->sq->ctrl;
>   	int ret = 0;
>   	int hash_len = nvme_auth_hmac_hash_len(ctrl->shash_id);
> -	int data_size = sizeof(*data) + hash_len;
> +	size_t data_size = sizeof(*data) + hash_len;
>   
>   	if (ctrl->dh_tfm)
>   		data_size += ctrl->dh_keysize;
> @@ -488,7 +488,7 @@ static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al)
>   	return ret;
>   }
>   
> -static int nvmet_auth_success1(struct nvmet_req *req, void *d, int al)
> +static int nvmet_auth_success1(struct nvmet_req *req, void *d, u32 al)
>   {
>   	struct nvmf_auth_dhchap_success1_data *data = d;
>   	struct nvmet_ctrl *ctrl = req->sq->ctrl;

Reviewed-by: Hannes Reinecke <hare@kernel.org>

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

      parent reply	other threads:[~2026-11-03  7:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-31  7:59 Sreeraj S Kurup
2026-10-31  8:17 ` [PATCH v2] " Sreeraj S Kurup
2026-11-03  5:38   ` Christoph Hellwig
2026-11-03 15:37   ` Keith Busch
2026-11-03  7:36 ` Hannes Reinecke [this message]

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=5deeca7b-8891-42b4-bcff-e8cc566409bb@suse.de \
    --to=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=sreekuttan2156239@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®