All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Maurizio Lombardi" <mlombard@arkamax.eu>
To: "Daniel Wagner" <dwagner@suse.de>,
	"Maurizio Lombardi" <mlombard@redhat.com>
Cc: <kbusch@kernel.org>, <linux-nvme@lists.infradead.org>,
	<mlombard@arkamax.eu>, <hch@lst.de>, <hare@suse.de>
Subject: Re: [PATCH] nvme: do not reset controllers in NVME_CTRL_NEW state
Date: Tue, 15 Sep 2026 15:49:36 +0200	[thread overview]
Message-ID: <DLFXS43UXYEC.MEIQ5NBK049N@arkamax.eu> (raw)
In-Reply-To: <e6146839-0a52-45d0-8b95-9ae0f7807493@flourine.local>

On Tue Sep 15, 2026 at 3:11 PM CEST, Daniel Wagner wrote:
> On Tue, Sep 15, 2026 at 11:58:27AM +0200, Maurizio Lombardi wrote:
>> 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 or why it was
>> there it there in the first place
>
> Looks reasonable. It might be worth explaining why we don't need to
> handle the NEW -> RESETTING state transition or why it was there in the
> first place.

Maybe the last paragraph could be expanded in the following way:

"
 Fix this by removing NVME_CTRL_NEW from the allowed prior states for
 the NVME_CTRL_RESETTING transition. It is safe to drop this transition
 entirely because a controller in the NVME_CTRL_NEW state is merely
 allocated and not yet initialized, a reset operation at this stage is
 meaningless.
"

For what concernes the "why it was there in the first place" question,
I think that the reason is that in ancient times a CONNECTING state
didn't exist. The controller initialization was done via a reset;
so the transition was NEW -> RESETTING -> LIVE.

Maurizio




  reply	other threads:[~2026-09-15 13:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=DLFXS43UXYEC.MEIQ5NBK049N@arkamax.eu \
    --to=mlombard@arkamax.eu \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=mlombard@redhat.com \
    /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 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.