From: Dave Jiang <dave.jiang@intel.com>
To: Alison Schofield <alison.schofield@intel.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Jonathan Cameron <jic23@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <iweiny@kernel.org>, Li Ming <ming.li@zohomail.com>,
Richard Cheng <icheng@nvidia.com>,
Ben Cheatham <benjamin.cheatham@amd.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH] cxl/region: Remove the AUTO_STAGED endpoint decoder state
Date: Tue, 1 Dec 2026 13:52:34 -0700 [thread overview]
Message-ID: <0e0c4ec6-9fc4-4160-8d84-6d24fd7d161d@intel.com> (raw)
In-Reply-To: <20261201201413.505714-1-alison.schofield@intel.com>
On 12/1/26 1:14 PM, Alison Schofield wrote:
> Dan added a new decoder state, AUTO_STAGED, to trigger cleanup when
> an endpoint decoder was unregistered while waiting for its peers.
> The cleanup used cxled->pos to find the target entry.
>
> Since commit cbda6a2c2bec ("cxl/region: Fix out-of-bounds access in
> cxl_cancel_auto_attach()"), the cleanup scans for the decoder pointer
> and no longer depends on cxled->pos.
>
> Dave Jiang [1] reported a use-after-free during region teardown
> because AUTO_STAGED is lost when an upstream attach fails and unwinds.
> That prompted another look at the state. The scan already determines
> whether there is a target entry to remove, so AUTO_STAGED is redundant.
>
> Drop the state and run the lookup when an AUTO decoder is unregistered
> with no cxld->region. This covers both decoders waiting for peers
> (Dan's case) and decoders left in the array after unwind (Dave's case).
>
> [1] https://patch.msgid.link/20261120181228.1466310-1-dave.jiang@intel.com
>
> Fixes: 87805c32e6ad ("cxl/region: Fix use-after-free from auto assembly failure")
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/cxl/core/region.c | 12 +-----------
> drivers/cxl/cxl.h | 6 ++----
> 2 files changed, 3 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index f8c88113de35..b30d9705fb00 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1105,14 +1105,6 @@ static int cxl_rr_ep_add(struct cxl_region_ref *cxl_rr,
>
> if (!cxld->region) {
> cxld->region = cxlr;
> -
> - /*
> - * Now that cxld->region is set the intermediate staging state
> - * can be cleared.
> - */
> - if (cxld == &cxled->cxld &&
> - cxled->state == CXL_DECODER_STATE_AUTO_STAGED)
> - cxled->state = CXL_DECODER_STATE_AUTO;
> get_device(&cxlr->dev);
> }
>
> @@ -1876,7 +1868,6 @@ static int cxl_region_attach_auto(struct cxl_region *cxlr,
>
> p->targets[pos] = cxled;
> cxled->pos = pos;
> - cxled->state = CXL_DECODER_STATE_AUTO_STAGED;
> p->nr_targets++;
>
> return 0;
> @@ -2247,7 +2238,6 @@ static int cxl_region_remove_target(struct device *dev, void *data)
> for (i = 0; i < p->interleave_ways; i++) {
> if (p->targets[i] == cxled) {
> p->nr_targets--;
> - cxled->state = CXL_DECODER_STATE_AUTO;
> cxled->pos = -1;
> p->targets[i] = NULL;
>
> @@ -2264,7 +2254,7 @@ static int cxl_region_remove_target(struct device *dev, void *data)
> */
> static void cxl_cancel_auto_attach(struct cxl_endpoint_decoder *cxled)
> {
> - if (cxled->state != CXL_DECODER_STATE_AUTO_STAGED)
> + if (cxled->state != CXL_DECODER_STATE_AUTO)
> return;
>
> bus_for_each_dev(&cxl_bus_type, NULL, cxled, cxl_region_remove_target);
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index baa6df2d362a..ceabc9dfba47 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -314,14 +314,12 @@ struct cxl_decoder {
> };
>
> /*
> - * Track whether this decoder is free for userspace provisioning, reserved for
> - * region autodiscovery, whether it is started connecting (awaiting other
> - * peers), or has completed auto assembly.
> + * Track whether this decoder is reserved for region autodiscovery, or
> + * free for userspace provisioning.
> */
> enum cxl_decoder_state {
> CXL_DECODER_STATE_MANUAL,
> CXL_DECODER_STATE_AUTO,
> - CXL_DECODER_STATE_AUTO_STAGED,
> };
>
> /**
>
> base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
prev parent reply other threads:[~2026-12-01 20:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 20:14 [PATCH] cxl/region: Remove the AUTO_STAGED endpoint decoder state Alison Schofield
2026-12-01 20:52 ` Dave Jiang [this message]
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=0e0c4ec6-9fc4-4160-8d84-6d24fd7d161d@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=benjamin.cheatham@amd.com \
--cc=dave@stgolabs.net \
--cc=icheng@nvidia.com \
--cc=iweiny@kernel.org \
--cc=jic23@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 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.