* [PATCH] nvmet-auth: Synchronize timeout work during SQ teardown
@ 2026-08-30 13:11 Kazuki Hanai
2026-08-30 20:53 ` Sagi Grimberg
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kazuki Hanai @ 2026-08-30 13:11 UTC (permalink / raw)
To: linux-nvme
Cc: hare, hch, sagi, kch, axboe, linux-kernel, Kazuki Hanai, stable
nvmet_auth_sq_free() cancels auth_expired_work with
cancel_delayed_work(). If the work has already started, cancellation does
not wait for the callback. Transport teardown can consequently free or
reuse the queue containing struct nvmet_sq while
nvmet_auth_expired_work() still accesses that SQ.
Add a teardown-specific helper that synchronously drains the delayed work
before freeing authentication state, and use it from nvmet_sq_destroy().
Keep the non-synchronous helper for in-band authentication state cleanup,
where the SQ owner remains alive.
Fixes: 1a70200f404a ("nvmet-auth: expire authentication sessions")
Cc: stable@vger.kernel.org
Signed-off-by: Kazuki Hanai <hnkz.64@gmail.com>
---
drivers/nvme/target/auth.c | 6 ++++++
drivers/nvme/target/core.c | 2 +-
drivers/nvme/target/nvmet.h | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c
index edb9627d97b09..a55319bcdbd13 100644
--- a/drivers/nvme/target/auth.c
+++ b/drivers/nvme/target/auth.c
@@ -238,6 +238,12 @@ void nvmet_auth_sq_free(struct nvmet_sq *sq)
sq->dhchap_skey = NULL;
}
+void nvmet_auth_sq_destroy(struct nvmet_sq *sq)
+{
+ cancel_delayed_work_sync(&sq->auth_expired_work);
+ nvmet_auth_sq_free(sq);
+}
+
void nvmet_destroy_auth(struct nvmet_ctrl *ctrl)
{
ctrl->shash_id = 0;
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index d74c01c98f194..4b48ca78ce5a8 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -980,7 +980,7 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)
wait_for_completion(&sq->confirm_done);
wait_for_completion(&sq->free_done);
percpu_ref_exit(&sq->ref);
- nvmet_auth_sq_free(sq);
+ nvmet_auth_sq_destroy(sq);
nvmet_cq_put(sq->cq);
/*
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index e362d7913a380..dbda55895f4fb 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -924,6 +924,7 @@ u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq, bool reset);
void nvmet_auth_sq_init(struct nvmet_sq *sq);
void nvmet_destroy_auth(struct nvmet_ctrl *ctrl);
void nvmet_auth_sq_free(struct nvmet_sq *sq);
+void nvmet_auth_sq_destroy(struct nvmet_sq *sq);
int nvmet_setup_dhgroup(struct nvmet_ctrl *ctrl, u8 dhgroup_id);
bool nvmet_check_auth_status(struct nvmet_req *req);
int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
@@ -950,6 +951,7 @@ static inline void nvmet_auth_sq_init(struct nvmet_sq *sq)
}
static inline void nvmet_destroy_auth(struct nvmet_ctrl *ctrl) {};
static inline void nvmet_auth_sq_free(struct nvmet_sq *sq) {};
+static inline void nvmet_auth_sq_destroy(struct nvmet_sq *sq) {};
static inline bool nvmet_check_auth_status(struct nvmet_req *req)
{
return true;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] nvmet-auth: Synchronize timeout work during SQ teardown
2026-08-30 13:11 [PATCH] nvmet-auth: Synchronize timeout work during SQ teardown Kazuki Hanai
@ 2026-08-30 20:53 ` Sagi Grimberg
2026-09-02 13:34 ` Christoph Hellwig
2026-09-02 22:31 ` Keith Busch
2 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2026-08-30 20:53 UTC (permalink / raw)
To: Kazuki Hanai, linux-nvme; +Cc: hare, hch, kch, axboe, linux-kernel, stable
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmet-auth: Synchronize timeout work during SQ teardown
2026-08-30 13:11 [PATCH] nvmet-auth: Synchronize timeout work during SQ teardown Kazuki Hanai
2026-08-30 20:53 ` Sagi Grimberg
@ 2026-09-02 13:34 ` Christoph Hellwig
2026-09-02 22:31 ` Keith Busch
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-09-02 13:34 UTC (permalink / raw)
To: Kazuki Hanai
Cc: linux-nvme, hare, hch, sagi, kch, axboe, linux-kernel, stable
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmet-auth: Synchronize timeout work during SQ teardown
2026-08-30 13:11 [PATCH] nvmet-auth: Synchronize timeout work during SQ teardown Kazuki Hanai
2026-08-30 20:53 ` Sagi Grimberg
2026-09-02 13:34 ` Christoph Hellwig
@ 2026-09-02 22:31 ` Keith Busch
2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2026-09-02 22:31 UTC (permalink / raw)
To: Kazuki Hanai
Cc: linux-nvme, hare, hch, sagi, kch, axboe, linux-kernel, stable
On Sun, Aug 30, 2026 at 10:11:05PM +0900, Kazuki Hanai wrote:
> nvmet_auth_sq_free() cancels auth_expired_work with
> cancel_delayed_work(). If the work has already started, cancellation does
> not wait for the callback. Transport teardown can consequently free or
> reuse the queue containing struct nvmet_sq while
> nvmet_auth_expired_work() still accesses that SQ.
>
> Add a teardown-specific helper that synchronously drains the delayed work
> before freeing authentication state, and use it from nvmet_sq_destroy().
> Keep the non-synchronous helper for in-band authentication state cleanup,
> where the SQ owner remains alive.
Thanks, applied to nvme-7.3.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-02 22:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-30 13:11 [PATCH] nvmet-auth: Synchronize timeout work during SQ teardown Kazuki Hanai
2026-08-30 20:53 ` Sagi Grimberg
2026-09-02 13:34 ` Christoph Hellwig
2026-09-02 22:31 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®