[PATCH 04/10] nvme: add nvme_auth_derive_tls_psk()

Christoph Hellwig hch at lst.de
Tue Jan 28 00:58:33 PST 2025


> +	info_len = strlen(psk_digest) + strlen(psk_prefix) + 5;

Where does the magic 5 come from?

>
> +	info = kzalloc(info_len, GFP_KERNEL);
> +	if (!info) {
> +		ret = -ENOMEM;
> +		goto out_free_prk;
> +	}
> +
> +	put_unaligned_be16(psk_len, info);
> +	memcpy(info + 2, psk_prefix, strlen(psk_prefix));
> +	sprintf(info + 2 + strlen(psk_prefix), "%02d %s", hmac_id, psk_digest);

And this feels like we'd want a basic struct for this, even if it
just is the len field and a flexible array.  Which will also help the
compiler to to do bounds checking using __counted_by.




More information about the Linux-nvme mailing list