Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795056163; b=HbrsWk6nQ7gC7yP0H8eHOyrMmo/bYMEPd3J9Hunf2PUAV4bfPKjTmYlCO8CHwpqlbHTZ SuUQgVLZiE0sXyaQmUOMw7m9borpeMsKGK+EK38HHY6gIRSxeZFFM+rf7iT3Ji+P2FhCQ aqhfcCzWOLGftql+LMppey3ng4vVwOhK4mgZXFmjvmsaYM2Um8Gz/kRnwSQVJJYYIra8w 11pWad1K7RMYkZmpCveq3277BaasM6ct7q1ecQ9RI5j0R7C23mom/muNJYXIQqJG8zTvU o/FK/KgknImzMEipOjjLGBhTfvnZEnPBjeOTTxP75Z2Q01phH4xtLO4QmHoB2X5QsrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795056163; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=vPare9Nl6fnDYXTRE6F/5soXtgw3YvlhLX+1/dtgFSM=; b=mxSenjFciqS97xfHc4fH9xt6A60K2Cv29y4TRrrVBz2ai/t8ai/mAUFp6vN8OafkvIsC aVmqD7Imep1VVGc16FtleLy904tWp8TCB9fR00qo4JP7dJWkaMsJYJ0cVgSufLaKhsdfE Iq4W79WtgKyI0NnEQ0oSyFoABo/+PfCygz3dMvrwTKiVoK3YUEzbb4J6+NnnU6Qe+TxXr h1WR84Zyasjvw6SZloeT2BTeUggE98yJN6YfjG4Vj+1n53F05a0Khqi35eXl7YxL1xlNi CgIcgsoiEDTPitDEmIyNWX/pxOWibXmOheJLl3/ynqZVouekxSrPkVbEv3YfouSPoNQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=cKzrYvC6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B769B606A32F; Thu, 19 Nov 2026 02:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=cKzrYvC6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E20C1F000C4; Thu, 19 Nov 2026 02:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795056163; bh=vPare9Nl6fnDYXTRE6F/5soXtgw3YvlhLX+1/dtgFSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cKzrYvC6AxPJxi9oBmr7aKXhQCwFB93+zmamaGSwkgUOTa+t+1qaiwOJtDmWcYAzw nCFS7dc/vjOkqYpcDRBr+YA/gzl/Ft1IfNikphQLJfqQ4Ar87BCK1dBL4RPtbjYEW3 jfZc3qvQdvSYM3DisVbc5UHMvKkaXrxpiTXHQdJ0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+da94a51633758d13bd63@syzkaller.appspotmail.com, Daniel Wagner , Christoph Hellwig , Palla Raghunath , Keith Busch , Sasha Levin Subject: [PATCH 5.15 1889/2214] nvmet-fc: dont drop the last assoc reference in nvmet_fc_delete_ctrl() Date: Wed, 18 Nov 2026 15:59:25 +0100 Message-ID: <20261118150126.777025276@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Palla Raghunath [ Upstream commit 165301b5e2fd765fa05ea1044bbca8ba79820197 ] syzbot hit a recursive locking report on subsys->lock when a subsystem is unlinked from an FC port. nvmet_port_del_ctrls() holds subsys->lock while it calls ->delete_ctrl() for each controller. nvmet_fc_delete_ctrl() grabs a reference on the association, queues del_work and then drops the reference. If del_work gets to run to completion before that put, ours is the last reference. Freeing the assoc tears down the queues, the last nvmet_cq_put() drops the last ctrl reference, and nvmet_ctrl_free() goes for subsys->lock again: WARNING: possible recursive locking detected ... nvmet_ctrl_free+0xa6/0x8e0 drivers/nvme/target/core.c:1766 nvmet_cq_put+0x158/0x200 drivers/nvme/target/core.c:848 nvmet_fc_target_assoc_free+0x418/0x2220 drivers/nvme/target/fc.c:1173 nvmet_fc_delete_ctrl+0x717/0x7e0 drivers/nvme/target/fc.c:1581 nvmet_port_del_ctrls+0xfb/0x150 drivers/nvme/target/core.c:311 nvmet_port_subsys_drop_link+0x1e8/0x310 drivers/nvme/target/configfs.c:1119 It's a real hang, not only a lockdep warning. I reproduced it with fcloop by putting an msleep() before the put: rm on the configfs link gets stuck in D state for good. I don't think we need that reference at all. del_work does list_del_rcu() and synchronize_rcu() before it drops the initial reference, so an assoc we find on assoc_list can't go away before rcu_read_unlock(). nvmet_fc_schedule_delete_assoc() doesn't sleep, so just call it inside the RCU section and get rid of the get/put. If the assoc is already being deleted, terminating is set and the call is a no-op, which matches what happened before when the get failed. With the same msleep() in place the patched kernel unlinks cleanly and the assoc is freed from the workqueue. Fixes: 4049dc96b8de ("nvmet-fc: defer cleanup using RCU properly") Reported-by: syzbot+da94a51633758d13bd63@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=da94a51633758d13bd63 Reviewed-by: Daniel Wagner Reviewed-by: Christoph Hellwig Signed-off-by: Palla Raghunath Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/fc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 28ad8de903ff0..8580afd8327ea 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1575,8 +1575,14 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl) list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { queue = assoc->queues[0]; if (queue && queue->nvme_sq.ctrl == ctrl) { - if (nvmet_fc_tgt_a_get(assoc)) - found_ctrl = true; + /* + * No assoc reference here: we're called with + * subsys->lock held, and if del_work beat us, + * our put would free the ctrl under that lock. + * RCU keeps the assoc alive until unlock. + */ + nvmet_fc_schedule_delete_assoc(assoc); + found_ctrl = true; break; } } @@ -1584,11 +1590,8 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl) nvmet_fc_tgtport_put(tgtport); - if (found_ctrl) { - nvmet_fc_schedule_delete_assoc(assoc); - nvmet_fc_tgt_a_put(assoc); + if (found_ctrl) return; - } spin_lock_irqsave(&nvmet_fc_tgtlock, flags); } -- 2.53.0