From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3C2A38DC44; Sat, 17 Oct 2026 16:50:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792255817; cv=none; b=jRNIa1+J9qKnWLFa4bafdegJgZJEcFcViuF6yfrlvZpCK/fc+zaFDo4Bx0nFRyYMutvNave5ZzQGg9Ue1tF/IYfDTYAs9uP9i0DNyoM1BToWAEA6dC3fA5Edu4b+sO203Xa5ho5ozwmJSMxha8+TV8s/HsmNtt7nkeiEOLxdokk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792255817; c=relaxed/simple; bh=5e2N0+N6XUeawJJS7ah977IMSXWLM2v3DRyvkhG2u1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xhbb/Q/kO73Y6vXPrCUZpHwiLCCtgpMWu43hbKVLqKxMHCMLMLc9nOmwbtAhCaN7WyNwpywsMDA43NhhYpHee2cjMYDn9gJ0iRmiT6DwgZ6WkTcgnGkxqQZ17YZAqoijvMlTadiHWuUoI/Yrdud1wl3sQfCmw3V1N3AIEJZnwck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X3bZ4T8d; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="X3bZ4T8d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 329E81F000C5; Sat, 17 Oct 2026 16:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792255816; bh=u2LThS4bYvhixDEYdGelMsO0SvDS2mQjxrd0tZZ8YmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X3bZ4T8dsNgMkJxIqtB2B+elUxENQSXH2FkH3b83DpGUy1kfFdN9rRhSBwdFWOxOU Z/tiJjPcdOPioipxLvTEi4LwZDDixwhdosu2mo/58Bop0VpJtobZFP35IwJdRgPRK/ oS4bUw0yoGg3ttUUMtXM3b15tRCD6M9TCS3TyqsE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tristan Madani , Sagi Grimberg , John Garry , Christoph Hellwig , Keith Busch , Sasha Levin Subject: [PATCH 6.6 0024/1674] nvme: add missing SRCU grace period in error path Date: Sat, 17 Oct 2026 17:38:16 +0200 Message-ID: <20261017160431.760420093@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tristan Madani [ Upstream commit ef248d5de4469fb6bbaf8dbe0c4c47800080d648 ] nvme_alloc_ns() error path at out_unlink_ns removes ns from the namespace head siblings list with list_del_rcu(&ns->siblings) but does not wait for SRCU readers before freeing the namespace struct. Multipath code iterates the head->list under srcu_read_lock() in nvme_find_path() and nvme_mpath_revalidate_paths(), so a concurrent reader can still hold a reference to ns when kfree(ns) runs. The normal removal path in nvme_ns_remove() correctly calls synchronize_srcu(&ns->head->srcu) after list_del_rcu() to wait for in-progress readers. Add the same grace period in the error path. Fixes: ed754e5deeb1 ("nvme: track shared namespaces") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani Reviewed-by: Sagi Grimberg Reviewed-by: John Garry Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch [ Adjusted patch context to account for missing last_path reference-counting code. ] Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d02ca033db439..c34ecb2c96562 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3699,6 +3699,9 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info) if (list_empty(&ns->head->list)) list_del_init(&ns->head->entry); mutex_unlock(&ctrl->subsys->lock); + + /* guarantee not available in head->list */ + synchronize_srcu(&ns->head->srcu); nvme_put_ns_head(ns->head); out_cleanup_disk: put_disk(disk); -- 2.53.0