Linux CXL
 help / color / mirror / Atom feed
* [PATCH v4 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN
@ 2026-11-03 17:07 Alison Schofield
  2026-11-03 17:07 ` [PATCH v4 2/2] cxl/Documentation: Describe clearing a region targetN position Alison Schofield
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Alison Schofield @ 2026-11-03 17:07 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Li Ming, Richard Cheng
  Cc: linux-cxl

Writing an endpoint decoder to a region targetN attribute that already
holds it returns -EBUSY, but leaves the partially populated region in an
inconsistent state. The targetN attribute still names the decoder, so the
failed write gives no indication that the region was damaged.

Filling the remaining target positions can then trigger a NULL pointer
dereference in cxl_region_setup_targets(). This can be reproduced through
sysfs:

    echo $decoder > /sys/bus/cxl/devices/region0/target0
    echo $decoder > /sys/bus/cxl/devices/region0/target0
    echo $other_decoder > /sys/bus/cxl/devices/region0/target1

An existing check recognizes the repeated assignment but incorrectly allows
the attachment to proceed, damaging region state. Remove that check so the
repeated write is rejected without disturbing the existing attachment,
consistent with the documented targetN ABI.

Fixes: 9995576cef48 ("cxl/region: Move region-position validation to a helper")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---

Note: cxl_region_perf_data_calculate() currently updates region performance
data before attachment validation completes. This is a pre-existing issue
that will be addressed separately.

Changes in v4:
- Drop the added useless check in cxl_region_attach() (Sashiko)
  The pre-existing occupied position check already returns -EBUSY.
v3: https://lore.kernel.org/linux-cxl/3e5af9d6d59f8df52b9d21bcf1c7e78f06918f80.1793653629.git.alison.schofield@intel.com/

Changes in v3:
- Reject repeat writes with -EBUSY, consistent with the documented ABI
- Rebase on 7.4-rc1
v2: https://lore.kernel.org/linux-cxl/920d80735a449f93a1f17a8bca4c25e4b302cb42.1792989098.git.alison.schofield@intel.com/

Changes in v2:
- Preserve the successful no-op behavior for repeated writes (Jonathan)
- Correct the Fixes tag
v1: https://lore.kernel.org/linux-cxl/94e9157aac2e99df1251d733769d539b914fdefc.1790829690.git.alison.schofield@intel.com/
---
 drivers/cxl/core/region.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index a048bd5c06cb..f42c6b6e3213 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1764,9 +1764,6 @@ static int cxl_region_validate_position(struct cxl_region *cxlr,
 		return -ENXIO;
 	}
 
-	if (p->targets[pos] == cxled)
-		return 0;
-
 	if (p->targets[pos]) {
 		struct cxl_endpoint_decoder *cxled_target = p->targets[pos];
 		struct cxl_memdev *cxlmd_target = cxled_to_memdev(cxled_target);

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-16 22:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 17:07 [PATCH v4 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN Alison Schofield
2026-11-03 17:07 ` [PATCH v4 2/2] cxl/Documentation: Describe clearing a region targetN position Alison Schofield
2026-11-03 23:07   ` Dave Jiang
2026-11-04  3:19     ` Alison Schofield
2026-11-03 21:27 ` [PATCH v4 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN Cheatham, Benjamin
2026-11-03 23:06 ` Dave Jiang
2026-11-11 19:47 ` Jonathan Cameron
2026-11-16 22:12 ` Dave Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox