aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-08-17 08:10:00 -0400
committerChristoph Hellwig <hch@lst.de>2017-08-29 04:23:04 -0400
commit1d5df6af8c7469f9ae3e66e7bed0782cfe4f95db (patch)
tree51a42a4473f95212102380d2eced64e970a1576c
parentcdbff4f26bd9fab11bfac22097f836892a5c3612 (diff)
nvme: don't blindly overwrite identifiers on disk revalidate
Instead validate that these identifiers do not change, as that is prohibited by the specification. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <keith.busch@intel.com>
-rw-r--r--drivers/nvme/host/core.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b87cf3a6e9ac..b0dd58db110e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1236,6 +1236,8 @@ static int nvme_revalidate_disk(struct gendisk *disk)
1236 struct nvme_ns *ns = disk->private_data; 1236 struct nvme_ns *ns = disk->private_data;
1237 struct nvme_ctrl *ctrl = ns->ctrl; 1237 struct nvme_ctrl *ctrl = ns->ctrl;
1238 struct nvme_id_ns *id; 1238 struct nvme_id_ns *id;
1239 u8 eui64[8] = { 0 }, nguid[16] = { 0 };
1240 uuid_t uuid = uuid_null;
1239 int ret = 0; 1241 int ret = 0;
1240 1242
1241 if (test_bit(NVME_NS_DEAD, &ns->flags)) { 1243 if (test_bit(NVME_NS_DEAD, &ns->flags)) {
@@ -1252,7 +1254,15 @@ static int nvme_revalidate_disk(struct gendisk *disk)
1252 goto out; 1254 goto out;
1253 } 1255 }
1254 1256
1255 nvme_report_ns_ids(ctrl, ns->ns_id, id, ns->eui, ns->nguid, &ns->uuid); 1257 nvme_report_ns_ids(ctrl, ns->ns_id, id, eui64, nguid, &uuid);
1258 if (!uuid_equal(&ns->uuid, &uuid) ||
1259 memcmp(&ns->nguid, &nguid, sizeof(ns->nguid)) ||
1260 memcmp(&ns->eui, &eui64, sizeof(ns->eui))) {
1261 dev_err(ctrl->device,
1262 "identifiers changed for nsid %d\n", ns->ns_id);
1263 ret = -ENODEV;
1264 }
1265
1256out: 1266out:
1257 kfree(id); 1267 kfree(id);
1258 return ret; 1268 return ret;