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 7/9] nvme-auth: wait for authentication to finish when changing keys
Date: Fri, 20 Nov 2026 15:52:41 +0100	[thread overview]
Message-ID: <039b2f6b-c24f-4e3d-8aae-33d592d26563@suse.de> (raw)
In-Reply-To: <sashiko-outbox-225036@kernel.org>

On 11/20/26 12:26 PM, sashiko-bot@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@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@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 14:52 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 [this message]
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
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=039b2f6b-c24f-4e3d-8aae-33d592d26563@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