All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN
@ 2026-10-01  4:56 Alison Schofield
  2026-10-01  4:56 ` [PATCH 2/2] cxl/Documentation: Describe clearing a region targetN position Alison Schofield
  2026-10-20 21:39 ` [PATCH 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN Jonathan Cameron
  0 siblings, 2 replies; 4+ messages in thread
From: Alison Schofield @ 2026-10-01  4:56 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(). Root can reproduce this
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

Reject a write to an already assigned position before modifying the region.

Fixes: b9686e8c8e39 ("cxl/region: Enable the assignment of endpoint decoders to regions")
Assisted-by: LLM
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---


An ndctl patch backstopping this fix in the cxl unit tests will follow.



 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 27e63e6dab7c..f9aafe89e5bb 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1762,9 +1762,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: cee9395acd8043be0644b25c34bfa86623f2b935
-- 
2.37.3


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

end of thread, other threads:[~2026-10-21  1:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-01  4:56 [PATCH 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN Alison Schofield
2026-10-01  4:56 ` [PATCH 2/2] cxl/Documentation: Describe clearing a region targetN position Alison Schofield
2026-10-20 21:39 ` [PATCH 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN Jonathan Cameron
2026-10-21  1:09   ` Alison Schofield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.