]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nvme: remove ns sibling before clearing path
authorKeith Busch <keith.busch@intel.com>
Fri, 5 Oct 2018 14:57:06 +0000 (08:57 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:12:16 +0000 (11:12 -0800)
[ Upstream commit 48f78be3326052a7718678ff9a78d6d884a50323 ]

The code had been clearing a namespace being deleted as the current
path while that namespace was still in the path siblings list. It is
possible a new IO could set that namespace back to the current path
since it appeared to be an eligable path to select, which may result in
a use-after-free error.

This patch ensures a namespace being removed is not eligable to be reset
as a current path prior to clearing it as the current path.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvme/host/core.c

index bf65501e6ed634a9e60c8c142955a16a60630159..f1f375fb362b530c50b528bf8a030208f42d77e2 100644 (file)
@@ -3119,8 +3119,8 @@ static void nvme_ns_remove(struct nvme_ns *ns)
        }
 
        mutex_lock(&ns->ctrl->subsys->lock);
-       nvme_mpath_clear_current_path(ns);
        list_del_rcu(&ns->siblings);
+       nvme_mpath_clear_current_path(ns);
        mutex_unlock(&ns->ctrl->subsys->lock);
 
        down_write(&ns->ctrl->namespaces_rwsem);