From: Alexander Duyck Date: Wed, 10 Oct 2018 23:38:41 +0000 (-0700) Subject: nvdimm: Sanity check labeloff X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~6089^2~12 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=d86d4d63d88861107d3bfc84be7294552231ecd0;p=linux.git nvdimm: Sanity check labeloff This patch adds validation for the labeloff field in the indexes. Reviewed-by: Toshi Kani Signed-off-by: Alexander Duyck Signed-off-by: Dan Williams --- diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c index 1d28cd656536..1f5842509dbc 100644 --- a/drivers/nvdimm/label.c +++ b/drivers/nvdimm/label.c @@ -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)