[PATCH v4 7/9] nvme-auth: wait for authentication to finish when changing keys
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Nov 20 03:26:22 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] nvme-auth: asymmetric and undocumented removal of
synchronize_rcu() in sysfs
--
commit 5f508c67e7480252b016c544aeba6f80edc88b85
Author: Hannes Reinecke <hare at kernel.org>
nvme-auth: wait for authentication to finish when changing keys
This commit flushes ctrl->dhchap_auth_work after queuing re-authentication in
dhchap_secret_store() and dhchap_ctrl_secret_store(), and removes two
synchronize_rcu() calls after key_revoke().
> diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
> index 47caed2ce3978..ce327a018b0d0 100644
> --- a/drivers/nvme/host/sysfs.c
> +++ b/drivers/nvme/host/sysfs.c
> @@ -875,7 +875,6 @@ static ssize_t dhchap_secret_store(struct device *dev,
> if (generated) {
> dev_dbg(ctrl->dev, "revoke host key %08x\n", key_serial(key));
> key_revoke(key);
> - synchronize_rcu();
> }
> key_put(key);
> kfree_sensitive(dhchap_secret);
[ ... ]
> @@ -973,7 +972,6 @@ static ssize_t dhchap_ctrl_secret_store(struct device *dev,
> dev_dbg(ctrl->dev, "revoke ctrl key %08x\n",
> key_serial(old_key));
> key_revoke(old_key);
> - synchronize_rcu();
> }
> ctrl->ctrl_key = key;
> ctrl->ctrl_key_generated = generated;
[Severity: Low]
Why are synchronize_rcu() calls removed from mismatched paths in
dhchap_secret_store() and dhchap_ctrl_secret_store(), and without mention in
the commit message?
In dhchap_secret_store(), synchronize_rcu() is removed from the
key_validate() error path, but kept when revoking old_key under
ctrl->dhchap_auth_mutex:
drivers/nvme/host/sysfs.c:dhchap_secret_store() {
...
if (ctrl->host_key_generated) {
dev_dbg(ctrl->dev, "revoke host key %08x\n",
key_serial(old_key));
key_revoke(old_key);
synchronize_rcu();
}
...
}
In dhchap_ctrl_secret_store(), it is removed when revoking old_key, but kept
in the key_validate() error path:
drivers/nvme/host/sysfs.c:dhchap_ctrl_secret_store() {
...
if (generated) {
dev_dbg(ctrl->dev, "revoke ctrl key %08x\n", key_serial(key));
key_revoke(key);
synchronize_rcu();
}
...
}
Both functions handle keys of type nvme_dhchap_psk_key_type (whose
user_revoke() callback frees the payload via call_rcu()), so the two store
callbacks should handle key_revoke() symmetrically.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-dhchap-keyring-v4-v4-0-5f8c7d9926ee@kernel.org?part=7
More information about the Linux-nvme
mailing list