Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d86d4d63 authored by Alexander Duyck's avatar Alexander Duyck Committed by Dan Williams
Browse files

nvdimm: Sanity check labeloff



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

Reviewed-by: default avatarToshi Kani <toshi.kani@hpe.com>
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent d11cf4a7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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)