nvdimm: Sanity check labeloff

This patch adds validation for the labeloff field in the indexes.

Reviewed-by: Toshi Kani <[email protected]>
Signed-off-by: Alexander Duyck <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
This commit is contained in:
Alexander Duyck 2018-10-10 16:38:41 -07:00 • committed by Dan Williams
commit d86d4d63d8

View file

@ -183,6 +183,13 @@ static int __nd_label_validate(struct nvdimm_drvdata *ndd)
__le64_to_cpu(nsindex[i]->otheroff));
continue;
}
if (__le64_to_cpu(nsindex[i]->labeloff)
!= 2 * sizeof_namespace_index(ndd)) {
dev_dbg(dev, "nsindex%d labeloff: %#llx invalid\n",
i, (unsigned long long)
__le64_to_cpu(nsindex[i]->labeloff));
continue;
}
size = __le64_to_cpu(nsindex[i]->mysize);
if (size > sizeof_namespace_index(ndd)