From: Jonathan Cameron <jic23@kernel.org>
To: Alison Schofield <alison.schofield@intel.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
Dave Jiang <dave.jiang@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <iweiny@kernel.org>, Li Ming <ming.li@zohomail.com>,
Richard Cheng <icheng@nvidia.com>,
linux-cxl@vger.kernel.org
Subject: Re: [PATCH 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN
Date: Tue, 20 Oct 2026 22:39:20 +0100 [thread overview]
Message-ID: <20261020223920.6147db30@jic23-hlaptop> (raw)
In-Reply-To: <94e9157aac2e99df1251d733769d539b914fdefc.1790829690.git.alison.schofield@intel.com>
On Wed, 30 Sep 2026 21:56:38 -0700
Alison Schofield <alison.schofield@intel.com> wrote:
> 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.
Rejecting a write that does nothing with an error isn't the nicest of
ABI choices - not to mention it's an ABI change (even if doesn't matter
much here given previously it probably crashed :).
Can we instead just reject much earlier before doing anything that
needs tearing down? Would moving the check to the top of
cxl_region_attach() work? There are some queries before that but
I don't think any of them update state and I think we
already have the stuff needed for a sanity check and early bail
out at that point.
I'm too lazy to actually test that theory so may well have missed something!
Thanks,
Jonathan
>
> 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
next prev parent reply other threads:[~2026-10-20 21:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Jonathan Cameron [this message]
2026-10-21 1:09 ` [PATCH 1/2] cxl/region: Reject a repeat write of an endpoint decoder to targetN Alison Schofield
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=20261020223920.6147db30@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=icheng@nvidia.com \
--cc=iweiny@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=ming.li@zohomail.com \
--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