[PATCH v4 7/9] nvme-auth: wait for authentication to finish when changing keys
Hannes Reinecke
hare at suse.de
Fri Nov 20 06:52:41 PST 2026
On 11/20/26 12:26 PM, sashiko-bot at kernel.org wrote:
> 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:
>
Oversight. Will be fixed up with the next version.
> 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.
>
Similarly. Will be fixed with the next round.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at 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
More information about the Linux-nvme
mailing list