Skip to content

Commit cd9aed6

Browse files
hreineckekeithbusch
authored andcommitted
nvme: catch errors from nvme_configure_metadata()
nvme_configure_metadata() is issuing I/O, so we might incur an I/O error which will cause the connection to be reset. But in that case any further probing will race with reset and cause UAF errors. So return a status from nvme_configure_metadata() and abort probing if there was an I/O error. Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 2344153 commit cd9aed6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/nvme/host/core.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,16 +1814,18 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)
18141814
return ret;
18151815
}
18161816

1817-
static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1817+
static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
18181818
{
18191819
struct nvme_ctrl *ctrl = ns->ctrl;
1820+
int ret;
18201821

1821-
if (nvme_init_ms(ns, id))
1822-
return;
1822+
ret = nvme_init_ms(ns, id);
1823+
if (ret)
1824+
return ret;
18231825

18241826
ns->features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS);
18251827
if (!ns->ms || !(ctrl->ops->flags & NVME_F_METADATA_SUPPORTED))
1826-
return;
1828+
return 0;
18271829

18281830
if (ctrl->ops->flags & NVME_F_FABRICS) {
18291831
/*
@@ -1832,7 +1834,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
18321834
* remap the separate metadata buffer from the block layer.
18331835
*/
18341836
if (WARN_ON_ONCE(!(id->flbas & NVME_NS_FLBAS_META_EXT)))
1835-
return;
1837+
return 0;
18361838

18371839
ns->features |= NVME_NS_EXT_LBAS;
18381840

@@ -1859,6 +1861,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
18591861
else
18601862
ns->features |= NVME_NS_METADATA_SUPPORTED;
18611863
}
1864+
return 0;
18621865
}
18631866

18641867
static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
@@ -2032,7 +2035,11 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
20322035
ns->lba_shift = id->lbaf[lbaf].ds;
20332036
nvme_set_queue_limits(ns->ctrl, ns->queue);
20342037

2035-
nvme_configure_metadata(ns, id);
2038+
ret = nvme_configure_metadata(ns, id);
2039+
if (ret < 0) {
2040+
blk_mq_unfreeze_queue(ns->disk->queue);
2041+
goto out;
2042+
}
20362043
nvme_set_chunk_sectors(ns, id);
20372044
nvme_update_disk_info(ns->disk, ns, id);
20382045

0 commit comments

Comments
 (0)