From: Dan Williams <dan.j.williams@intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
<linux-cxl@vger.kernel.org>, <dan.j.williams@intel.com>
Cc: <vishal.l.verma@intel.com>, <ira.weiny@intel.com>,
<alison.schofield@intel.com>, <linuxarm@huawei.com>,
Bobo WL <lmw.bobo@gmail.com>
Subject: RE: [PATCH] cxl/region: Fix null pointer dereference due to pass through decoder commit
Date: Thu, 18 Aug 2022 17:37:22 -0700 [thread overview]
Message-ID: <62fedb421d71f_11e5e3294bd@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20220818164210.2084-1-Jonathan.Cameron@huawei.com>
Jonathan Cameron wrote:
> Not all decoders have a commit callback.
>
> The CXL specification allows a host bridge with a single root port to
> have no explicit HDM decoders. Currently we assumes there are none.
> As such we create a special pass through decoder instance without
> a commit callback.
>
> Prior to this patch, the commit callback was called unconditionally.
> Thus a configuration with 1 Host Bridge, 1 Root Port, 1 switch with
> multiple downstream ports below which there are multiple CXL type 3
> devices results in a situation where committing the region causes
> a null pointer dereference.
>
> Reported-by: Bobo WL <lmw.bobo@gmail.com>
> Fixes: 176baefb2eb5 ("cxl/hdm: Commit decoder state to hardware")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>
> We could fix this with a stub function perhaps as an alternative?
How about keep the callback mandatory except for the passthrough switch
case?
Something like this (untested):
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 401148016978..b1137f6dc2d1 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -172,11 +172,17 @@ static int cxl_region_decode_commit(struct cxl_region *cxlr)
/* commit bottom up */
for (iter = cxled_to_port(cxled); !is_cxl_root(iter);
iter = to_cxl_port(iter->dev.parent)) {
+ struct cxl_switch_decoder *cxlsd = NULL;
+
cxl_rr = cxl_rr_load(iter, cxlr);
cxld = cxl_rr->decoder;
- rc = cxld->commit(cxld);
- if (rc)
- break;
+ if (is_switch_decoder(&cxld->dev))
+ cxlsd = to_cxl_switch_decoder(&cxld->dev);
+ if (cxld->commit || cxlsd && cxlsd->nr_targets > 1) {
+ rc = cxld->commit(cxld);
+ if (rc)
+ break;
+ }
}
if (rc) {
next prev parent reply other threads:[~2022-08-19 0:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-18 16:42 [PATCH] cxl/region: Fix null pointer dereference due to pass through decoder commit Jonathan Cameron
2022-08-18 17:45 ` Verma, Vishal L
2022-10-11 21:33 ` Dan Williams
2022-08-19 0:37 ` Dan Williams [this message]
2022-08-19 8:31 ` Jonathan Cameron
2022-10-10 16:11 ` Jonathan Cameron
2022-10-11 21:30 ` Dan Williams
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=62fedb421d71f_11e5e3294bd@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=lmw.bobo@gmail.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