[PATCH v6 7/9] nvme-auth: wait for authentication to finish when changing keys

From: Hannes Reinecke

Date: Mon Nov 23 2026 - 12:10:58 EST


When changing DH-HMAC-CHAP keys in sysfs we need to wait for authentication
to complete on all queues. Otherwise the user might change the keys while
authentication is in progress, causing the authentication to fail and
I/O to be interrupted.

Signed-off-by: Hannes Reinecke <hare@xxxxxxxxxx>
Reviewed-by: Sagi Grimberg <sagi@xxxxxxxxxxx>
---
drivers/nvme/host/sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index c94abb901a73c880d354d9c1223d89fe5c9b0e89..8b6e5409f4893d8e56ff6fb15a89b540b1f733da 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -911,7 +911,7 @@ static ssize_t dhchap_secret_store(struct device *dev,
/* Start re-authentication */
dev_info(ctrl->device, "re-authenticating controller\n");
queue_work(nvme_wq, &ctrl->dhchap_auth_work);
-
+ flush_work(&ctrl->dhchap_auth_work);
return count;
}

@@ -1011,7 +1011,7 @@ static ssize_t dhchap_ctrl_secret_store(struct device *dev,
/* Start re-authentication */
dev_info(ctrl->device, "re-authenticating controller\n");
queue_work(nvme_wq, &ctrl->dhchap_auth_work);
-
+ flush_work(&ctrl->dhchap_auth_work);
return count;
}


--
2.51.0