Skip to content

Commit 1d5df6a

Browse files
author
Christoph Hellwig
committed
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 <[email protected]> Reviewed-by: Keith Busch <[email protected]>
1 parent cdbff4f commit 1d5df6a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,8 @@ static int nvme_revalidate_disk(struct gendisk *disk)
12361236
struct nvme_ns *ns = disk->private_data;
12371237
struct nvme_ctrl *ctrl = ns->ctrl;
12381238
struct nvme_id_ns *id;
1239+
u8 eui64[8] = { 0 }, nguid[16] = { 0 };
1240+
uuid_t uuid = uuid_null;
12391241
int ret = 0;
12401242

12411243
if (test_bit(NVME_NS_DEAD, &ns->flags)) {
@@ -1252,7 +1254,15 @@ static int nvme_revalidate_disk(struct gendisk *disk)
12521254
goto out;
12531255
}
12541256

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+
12561266
out:
12571267
kfree(id);
12581268
return ret;

0 commit comments

Comments
 (0)