]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nfit_test: fix buffer overrun, add sanity check
authorRoss Zwisler <ross.zwisler@linux.intel.com>
Tue, 27 Feb 2018 17:29:51 +0000 (10:29 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 6 Mar 2018 19:05:37 +0000 (11:05 -0800)
commit9741a559971856fca61a83840b558b4f94500d89
treeab66750172619c8af0d38aeb85e60c6e8bcf84f2
parentd7d8464dcc27dfc9d0d23c7924b2e6f4bb16c6c2
nfit_test: fix buffer overrun, add sanity check

It turns out that we were overrunning the 'nfit_buf' buffer in
nfit_test0_setup() in the (t->setup_hotplug == 1) case because we failed to
correctly account for all of the acpi_nfit_memory_map structures.

Fix the structure count which will increase the allocation size of
'nfit_buf' in nfit_test0_alloc().  Also add some WARN_ON()s to
nfit_test0_setup() and nfit_test1_setup() to catch future issues where the
size of the buffer doesn't match the amount of data we're writing.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
tools/testing/nvdimm/test/nfit.c