From: sashiko-bot@kernel.org
To: "Guixin Liu" <kanie@linux.alibaba.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v3] cxl/region: Unregister the pmem region when the bridge is unbound
Date: Mon, 31 Aug 2026 06:26:32 +0000 [thread overview]
Message-ID: <20260831062632.AEECD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831061120.200790-1-kanie@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Race condition leading to NULL pointer dereference in cxl_pmem_region_probe().
--
commit 46b44f91e80687bcb216394e5b204e067ed40c6d
Author: Guixin Liu <kanie@linux.alibaba.com>
cxl/region: Unregister the pmem region when the bridge is unbound
This commit addresses an issue where removing cxl_acpi unbinds the nvdimm
bridge before the regions it serves, leaving an orphan pmem region. It
updates devm_cxl_add_pmem_region() to unregister the cxl_pmem_region
synchronously when the bridge is unbound.
> diff --git a/drivers/cxl/core/region_pmem.c b/drivers/cxl/core/region_pmem.c
> index 23d97e3d78b6a..7ab1373a95e01 100644
> --- a/drivers/cxl/core/region_pmem.c
> +++ b/drivers/cxl/core/region_pmem.c
> @@ -168,12 +168,14 @@ int devm_cxl_add_pmem_region(struct cxl_region *cxlr)
> dev_name(dev));
>
> scoped_guard(device, &cxl_nvb->dev) {
> - if (cxl_nvb->dev.driver)
> + if (cxl_nvb->dev.driver) {
> rc = devm_add_action_or_reset(&cxl_nvb->dev,
> cxlr_pmem_unregister,
> cxlr_pmem);
> - else
> + } else {
> rc = -ENXIO;
> + cxlr_pmem_unregister(cxlr_pmem);
[Severity: High]
This isn't a bug introduced by this patch, but this patch extends the
usage of cxlr_pmem_unregister() in the synchronous error path, keeping a
vulnerability active.
Can a race condition lead to a NULL pointer dereference in
cxl_pmem_region_probe()?
If the cxl_pmem driver is loaded (e.g., via modprobe) concurrently with the
unbinding of the cxl_acpi bridge (or if devm_cxl_add_pmem_region() fails on
the bridge unbound check), cxlr_pmem_unregister() is called on another CPU.
cxlr_pmem_unregister() sets the pointer to NULL without holding the region
device's lock:
drivers/cxl/core/region_pmem.c:cxlr_pmem_unregister() {
...
cxlr_pmem->cxlr = NULL;
device_unregister(&cxlr_pmem->dev);
...
}
Simultaneously, the driver core calls cxl_pmem_region_probe() which holds the
device lock, but reads the concurrently nullified pointer and dereferences it:
drivers/cxl/pmem.c:cxl_pmem_region_probe() {
...
struct cxl_region *cxlr = cxlr_pmem->cxlr;
struct cxl_nvdimm_bridge *cxl_nvb = cxlr->cxl_nvb;
...
}
Does this code open a race window against the probe function, resulting
in a crash?
> + }
> }
>
> if (rc)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831061120.200790-1-kanie@linux.alibaba.com?part=1
next prev parent reply other threads:[~2026-08-31 6:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 6:11 [PATCH v3] cxl/region: Unregister the pmem region when the bridge is unbound Guixin Liu
2026-08-31 6:26 ` sashiko-bot [this message]
2026-08-31 15:49 ` Dave Jiang
2026-09-14 21:07 ` Dave Jiang
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=20260831062632.AEECD1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kanie@linux.alibaba.com \
--cc=linux-cxl@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.