Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: sashiko-reviews@lists.linux.dev, Hannes Reinecke <hare@kernel.org>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH v4 8/9] nvme-fabrics: allow to pass in keyring by name
Date: Fri, 20 Nov 2026 16:02:38 +0100	[thread overview]
Message-ID: <f9ef564b-08ca-4e6e-905c-8554d653b174@suse.de> (raw)
In-Reply-To: <sashiko-outbox-225080@kernel.org>

On 11/20/26 12:37 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [High] nvme-fabrics: opt_tokens keyring=%d pattern rejects keyring
>    names
> - [Medium] nvme-fabrics: build failure in nvmf_parse_options() when
>    !CONFIG_KEYS
> --
> 
> commit 0ba36c8d6abaed9ca222b0bbab73723c1ce8243d
> Author: Hannes Reinecke <hare@kernel.org>
> 
> nvme-fabrics: allow to pass in keyring by name
> 
> This commit updates nvmf_parse_options() so the NVMF_OPT_KEYRING option
> falls back to looking up a keyring by description via request_key() when the
> argument is not a positive integer serial number.
> 
>> diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
>> index cd728768a68fc..71da67b543aa4 100644
>> --- a/drivers/nvme/host/fabrics.c
>> +++ b/drivers/nvme/host/fabrics.c
> 
> [ ... ]
> 
>> @@ -993,13 +994,23 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
>>   			break;
>>   		case NVMF_OPT_KEYRING:
>>   			if (match_int(args, &key_id) || key_id <= 0) {
>> -				ret = -EINVAL;
>> -				goto out;
>> -			}
>> -			key = nvmf_parse_key(key_id);
>> -			if (IS_ERR(key)) {
>> -				ret = PTR_ERR(key);
>> -				goto out;
>> +				p = match_strdup(args);
> 
> [Severity: High]
> Can a keyring name ever reach this branch while opt_tokens still defines
> NVMF_OPT_KEYRING as "keyring=%d"?
> 
> drivers/nvme/host/fabrics.c:opt_tokens {
>      ...
> 	{ NVMF_OPT_KEYRING,		"keyring=%d"		},
>      ...
> }
> 
> Because match_token() requires "%d" arguments to be valid integers, any
> non-numeric name such as "keyring=.nvme" fails to match and makes
> nvmf_parse_options() reject the option with -EINVAL in the default switch
> case.  In addition, reading /dev/nvme-fabrics still advertises "keyring=%d"
> to userspace, while passing a non-positive integer serial number such as
> "keyring=0" or "keyring=-1" enters this fallback and looks up the number as
> a keyring description instead of returning -EINVAL.
> 
Fixed with the next round.

>> +				if (!p) {
>> +					ret = -ENOMEM;
>> +					goto out;
>> +				}
>> +				key = request_key(&key_type_keyring, p, NULL);
> 
> [Severity: Medium]
> Does this break the build when CONFIG_NVME_FABRICS is enabled and
> CONFIG_KEYS is disabled?
> 
> CONFIG_NVME_FABRICS only selects CONFIG_NVME_KEYRING (which selects
> CONFIG_KEYS) when CONFIG_NVME_TCP_TLS or CONFIG_NVME_HOST_AUTH is enabled.
> Both key_type_keyring in include/linux/key-type.h and request_key() in
> include/linux/key.h are declared under #ifdef CONFIG_KEYS with no stub for
> !CONFIG_KEYS builds.
> 
Fixed with the next round.

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


  reply	other threads:[~2026-11-20 15:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 11:13 [PATCH v4 0/9] nvme-auth: switch to use the kernel keyring Hannes Reinecke
2026-11-20 11:14 ` [PATCH v4 1/9] nvme-auth: modify nvme_auth_transform_key() to return status Hannes Reinecke
2026-11-20 11:19   ` sashiko-bot
2026-11-20 11:42     ` Hannes Reinecke
2026-11-20 11:14 ` [PATCH v4 2/9] nvme-keyring: add 'dhchap' key type Hannes Reinecke
2026-11-20 11:28   ` sashiko-bot
2026-11-20 12:28     ` Hannes Reinecke
2026-11-20 11:14 ` [PATCH v4 3/9] nvme-auth: switch to use 'struct key' Hannes Reinecke
2026-11-20 11:31   ` sashiko-bot
2026-11-20 13:08     ` Hannes Reinecke
2026-11-20 11:14 ` [PATCH v4 4/9] nvme: parse dhchap keys during option parsing Hannes Reinecke
2026-11-20 11:32   ` sashiko-bot
2026-11-20 13:55     ` Hannes Reinecke
2026-11-20 11:14 ` [PATCH v4 5/9] nvmet-auth: parse dhchap key from configfs attribute Hannes Reinecke
2026-11-20 11:28   ` sashiko-bot
2026-11-20 14:15     ` Hannes Reinecke
2026-11-20 11:14 ` [PATCH v4 6/9] nvme: allow to pass in key description as dhchap secret Hannes Reinecke
2026-11-20 11:31   ` sashiko-bot
2026-11-20 14:48     ` Hannes Reinecke
2026-11-20 11:14 ` [PATCH v4 7/9] nvme-auth: wait for authentication to finish when changing keys Hannes Reinecke
2026-11-20 11:26   ` sashiko-bot
2026-11-20 14:52     ` Hannes Reinecke
2026-11-20 11:14 ` [PATCH v4 8/9] nvme-fabrics: allow to pass in keyring by name Hannes Reinecke
2026-11-20 11:37   ` sashiko-bot
2026-11-20 15:02     ` Hannes Reinecke [this message]
2026-11-20 11:14 ` [PATCH v4 9/9] nvmet: add configfs attribute 'dhchap_keyring' Hannes Reinecke
2026-11-20 11:39   ` sashiko-bot
2026-11-20 15:27     ` 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=f9ef564b-08ca-4e6e-905c-8554d653b174@suse.de \
    --to=hare@suse.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox