From: Dave Jiang <dave.jiang@intel.com>
To: Alison Schofield <alison.schofield@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>
Cc: nvdimm@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH v2] tools/testing/nvdimm: Use per-DIMM device handle
Date: Mon, 3 Nov 2025 08:32:08 -0700 [thread overview]
Message-ID: <01e17cd1-a48d-4bf5-8ec7-4c858d3d0f71@intel.com> (raw)
In-Reply-To: <20251031234227.1303113-1-alison.schofield@intel.com>
On 10/31/25 4:42 PM, Alison Schofield wrote:
> 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: 10246dc84dfc ("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>> ---
>
> Changes in v2:
> - Use the correct handle in per-DIMM test data (Dan)
> - Update commit message and log
> - Update Fixes Tag
>
>
> tools/testing/nvdimm/test/nfit.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
> index cfd4378e2129..f87e9f251d13 100644
> --- a/tools/testing/nvdimm/test/nfit.c
> +++ b/tools/testing/nvdimm/test/nfit.c
> @@ -670,6 +670,7 @@ static int nfit_test_search_spa(struct nvdimm_bus *bus,
> .addr = spa->spa,
> .region = NULL,
> };
> + struct nfit_mem *nfit_mem;
> u64 dpa;
>
> ret = device_for_each_child(&bus->dev, &ctx,
> @@ -687,8 +688,12 @@ static int nfit_test_search_spa(struct nvdimm_bus *bus,
> */
> nd_mapping = &nd_region->mapping[nd_region->ndr_mappings - 1];
> nvdimm = nd_mapping->nvdimm;
> + nfit_mem = nvdimm_provider_data(nvdimm);
> + if (!nfit_mem)
> + return -EINVAL;
>
> - spa->devices[0].nfit_device_handle = handle[nvdimm->id];
> + spa->devices[0].nfit_device_handle =
> + __to_nfit_memdev(nfit_mem)->device_handle;
> spa->num_nvdimms = 1;
> spa->devices[0].dpa = dpa;
>
>
> base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
next prev parent reply other threads:[~2025-11-03 15:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-31 23:42 [PATCH v2] tools/testing/nvdimm: Use per-DIMM device handle Alison Schofield
2025-11-03 15:32 ` Dave Jiang [this message]
2025-11-04 20:05 ` Ira Weiny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=01e17cd1-a48d-4bf5-8ec7-4c858d3d0f71@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=nvdimm@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox