mirror-linux/tools/testing/nvdimm
Alison Schofield f59b701b46 tools/testing/nvdimm: Use per-DIMM device handle
KASAN reports a global-out-of-bounds access when running these nfit
tests: clear.sh, pmem-errors.sh, pfn-meta-errors.sh, btt-errors.sh,
daxdev-errors.sh, and inject-error.sh.

[] BUG: KASAN: global-out-of-bounds in nfit_test_ctl+0x769f/0x7840 [nfit_test]
[] Read of size 4 at addr ffffffffc03ea01c by task ndctl/1215
[] The buggy address belongs to the variable:
[] handle+0x1c/0x1df4 [nfit_test]

nfit_test_search_spa() uses handle[nvdimm->id] to retrieve a device
handle and triggers a KASAN error when it reads past the end of the
handle array. It should not be indexing the handle array at all.

The correct device handle is stored in per-DIMM test data. Each DIMM
has a struct nfit_mem that embeds a struct acpi_nfit_memdev that
describes the NFIT device handle. Use that device handle here.

Fixes: 10246dc84d ("acpi nfit: nfit_test supports translate SPA")
Cc: stable@vger.kernel.org
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>> ---
Link: https://patch.msgid.link/20251031234227.1303113-1-alison.schofield@intel.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
2025-11-03 16:47:13 -06:00
..
test tools/testing/nvdimm: Use per-DIMM device handle 2025-11-03 16:47:13 -06:00
Kbuild tools/testing/nvdimm: Disable "missing prototypes / declarations" warnings 2024-01-22 10:41:59 -08:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
acpi_nfit_test.c tools/testing/nvdimm: Populate dirty shutdown data 2018-10-17 10:47:19 -07:00
config_check.c nvdimm/blk: Delete the block-aperture window driver 2022-03-11 15:53:12 -08:00
dax-dev.c device-dax: add dis-contiguous resource support 2020-10-13 18:38:28 -07:00
dax_pmem_test.c tools/testing/nvdimm: add watermarks for dax_pmem* modules 2019-04-22 15:56:28 -07:00
device_dax_test.c tools/testing/nvdimm: force nfit_test to depend on instrumented modules 2018-02-01 16:49:54 -08:00
libnvdimm_test.c tools/testing/nvdimm: force nfit_test to depend on instrumented modules 2018-02-01 16:49:54 -08:00
pmem-dax.c mm: remove callers of pfn_t functionality 2025-07-09 22:42:19 -07:00
pmem_test.c tools/testing/nvdimm: force nfit_test to depend on instrumented modules 2018-02-01 16:49:54 -08:00
watermark.h tools/testing/nvdimm: add watermarks for dax_pmem* modules 2019-04-22 15:56:28 -07:00