diff options
author | Alexander Duyck <alexander.h.duyck@linux.intel.com> | 2018-10-10 19:38:41 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2018-10-12 11:38:53 -0400 |
commit | d86d4d63d88861107d3bfc84be7294552231ecd0 (patch) | |
tree | c443baecbd8c87b53d4427a86329cb417c782857 | |
parent | d11cf4a7321b538563b0ab30dc0d1f18f9c56226 (diff) |
nvdimm: Sanity check labeloff
This patch adds validation for the labeloff field in the indexes.
Reviewed-by: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/nvdimm/label.c | 7 |
1 files changed, 7 insertions, 0 deletions
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) | |||
183 | __le64_to_cpu(nsindex[i]->otheroff)); | 183 | __le64_to_cpu(nsindex[i]->otheroff)); |
184 | continue; | 184 | continue; |
185 | } | 185 | } |
186 | if (__le64_to_cpu(nsindex[i]->labeloff) | ||
187 | != 2 * sizeof_namespace_index(ndd)) { | ||
188 | dev_dbg(dev, "nsindex%d labeloff: %#llx invalid\n", | ||
189 | i, (unsigned long long) | ||
190 | __le64_to_cpu(nsindex[i]->labeloff)); | ||
191 | continue; | ||
192 | } | ||
186 | 193 | ||
187 | size = __le64_to_cpu(nsindex[i]->mysize); | 194 | size = __le64_to_cpu(nsindex[i]->mysize); |
188 | if (size > sizeof_namespace_index(ndd) | 195 | if (size > sizeof_namespace_index(ndd) |