All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: do not reset controllers in NVME_CTRL_NEW state
@ 2026-09-15  9:58 Maurizio Lombardi
  2026-09-15 13:11 ` Daniel Wagner
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Maurizio Lombardi @ 2026-09-15  9:58 UTC (permalink / raw)
  To: kbusch; +Cc: linux-nvme, mlombard, hch, hare, dwagner

During NVMe controller creation, the controller is exposed to sysfs via
nvme_add_ctrl() while it is still in the NVME_CTRL_NEW state.
This creates a narrow race window where a userspace process can write to
the reset_controller sysfs node before the initialization thread
transitions the state to NVME_CTRL_CONNECTING.

If a reset is triggered during this window, the state machine allows the
transition from NVME_CTRL_NEW to NVME_CTRL_RESETTING, and the reset work
is queued. However, the original creation thread continues its execution,
subsequently moving the state to NVME_CTRL_CONNECTING and finally to
NVME_CTRL_LIVE.

When the delayed reset work finally executes, it attempts to tear down
the controller and transition the state to NVME_CTRL_CONNECTING. Because
the state is now NVME_CTRL_LIVE, this transition fails, triggering a
WARN_ON in the reset work.

Fix this by removing NVME_CTRL_NEW from the allowed prior states for
the NVME_CTRL_RESETTING transition.

Fixes: 8bfc3b4c6f9d ("nvmet: switch loopback target state to connecting when resetting")
Reported-by: syzbot+4a1d521d19d6321f5aad@syzkaller.appspotmail.com
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
 drivers/nvme/host/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index beea23d04a70..7ea8dd27d08d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -598,7 +598,6 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
 		break;
 	case NVME_CTRL_RESETTING:
 		switch (old_state) {
-		case NVME_CTRL_NEW:
 		case NVME_CTRL_LIVE:
 			changed = true;
 			atomic_long_inc(&ctrl->nr_reset);
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-10-05 13:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15  9:58 [PATCH] nvme: do not reset controllers in NVME_CTRL_NEW state Maurizio Lombardi
2026-09-15 13:11 ` Daniel Wagner
2026-09-15 13:49   ` Maurizio Lombardi
2026-09-15 14:49     ` Daniel Wagner
2026-09-15 16:42       ` Keith Busch
2026-09-17 19:48 ` Keith Busch
2026-10-03 11:55 ` Yureka Lilian
2026-10-03 12:33   ` Maurizio Lombardi
2026-10-03 13:09     ` Maurizio Lombardi
2026-10-03 14:22       ` Yureka Lilian
2026-10-05 13:05         ` Keith Busch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.