[PATCH v4 8/9] nvme-fabrics: allow to pass in keyring by name
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Nov 20 03:37:48 PST 2026
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 at 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.
> + 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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-dhchap-keyring-v4-v4-0-5f8c7d9926ee@kernel.org?part=8
More information about the Linux-nvme
mailing list