From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55E843D3D03; Thu, 15 Jan 2026 17:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498087; cv=none; b=DurjmIZ8xO5wpSsA55D36ABXVvH9vR5npwYEzlWuG0dsT7u6tbvnAdj/SWAHZY4LBwDxr7IcX4+ab50Au0eGIj9hnC9/mogCu540jkKmafhVASsZIx7L/UyBIlTW9CNo/LxKDTvX46KcvcZREt4jep4EwWTun0iEbFbu94FZXUI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498087; c=relaxed/simple; bh=S1llgWTLx5luKcqAFFiYFRm5JdXOR3PD05ND71+Hn60=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=glcnhj2gRGys0aTauRcHd5KYYbLazG4SF5ljuwfxsjb9ZMS88HoIR61VNq7MpP2pVs+JjIyTz+FAGQ2YZBW3k9CbxcAFziUM0XdwuYXVGJ3LbiHd26Py4PWEnxuFW0exIP3PMXHL5yUkMtjQ+RNrV6q1sYn+Xec6xhT9qHb78c8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=APrEhLZK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="APrEhLZK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F81C116D0; Thu, 15 Jan 2026 17:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768498087; bh=S1llgWTLx5luKcqAFFiYFRm5JdXOR3PD05ND71+Hn60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=APrEhLZKlX4fUDjz5mA4/WcyicNTlXrpLhKniJoTmGhJ3E6ZXF4H1UTLs6PTwx2S9 /TPQ2cN3HWtDr+Piwhu4niQvm0qCJoX70uM7OUxmV6Q9wp3A8RQBfkwVAI6FbXTi9O x9slzFqQ+OXJLUucz0fpRN+g1cv9N/kkR/joRKFs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alison Schofield , Ira Weiny , Dave Jiang Subject: [PATCH 5.15 307/554] tools/testing/nvdimm: Use per-DIMM device handle Date: Thu, 15 Jan 2026 17:46:13 +0100 Message-ID: <20260115164257.343923203@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164246.225995385@linuxfoundation.org> References: <20260115164246.225995385@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alison Schofield commit f59b701b4674f7955170b54c4167c5590f4714eb upstream. 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 Reviewed-by: Dave Jiang > --- Link: https://patch.msgid.link/20251031234227.1303113-1-alison.schofield@intel.com Signed-off-by: Ira Weiny Signed-off-by: Greg Kroah-Hartman --- tools/testing/nvdimm/test/nfit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -672,6 +672,7 @@ static int nfit_test_search_spa(struct n .addr = spa->spa, .region = NULL, }; + struct nfit_mem *nfit_mem; u64 dpa; ret = device_for_each_child(&bus->dev, &ctx, @@ -689,8 +690,12 @@ static int nfit_test_search_spa(struct n */ 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;