From: Dan Williams <dan.j.williams@intel.com>
To: Breno Leitao <leitao@debian.org>, <alison.schofield@intel.com>,
<vishal.l.verma@intel.com>, <ira.weiny@intel.com>,
<bwidawsk@kernel.org>, <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <dave.jiang@intel.com>
Subject: RE: [PATCH v3 1/2] cxl/acpi: Fix UAF in the error path
Date: Fri, 14 Jul 2023 20:16:15 -0700 [thread overview]
Message-ID: <64b20f7fc808e_45a62943b@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20230714093146.2253438-1-leitao@debian.org>
Breno Leitao wrote:
> KASAN and KFENCE detected an user-after-free in the CXL driver. This
> happens in the cxl_decoder_add() fail path. KASAN prints the following
> error:
>
> BUG: KASAN: slab-use-after-free in cxl_parse_cfmws (drivers/cxl/acpi.c:299)
>
> This is happening in cxl_parse_cfmws(), where put_device() is called,
> releasing cxld, which is accessed later.
>
> Just use the local variables in the dev_err() instead of pointing to the
> released memory.
>
> Fixes: e50fe01e1f2a ("cxl/core: Drop ->platform_res attribute for root decoders")
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> v1 -> v2
> * Return the error (rc) instead of swalling it
> v2 -> v3
> * Split the change in two patches
> * Fix the reference instead of the order
>
> drivers/cxl/acpi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
> index 658e6b84a769..642983da01cb 100644
> --- a/drivers/cxl/acpi.c
> +++ b/drivers/cxl/acpi.c
> @@ -297,7 +297,7 @@ static int cxl_parse_cfmws(union acpi_subtable_headers *header, void *arg,
> rc = cxl_decoder_autoremove(dev, cxld);
> if (rc) {
> dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
> - cxld->hpa_range.start, cxld->hpa_range.end);
> + res->start, res->end);
Came here after the 0day report...
Since this is switching the reuse @res, it can also switch to using %pr
to print the resource.
prev parent reply other threads:[~2023-07-15 3:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 9:31 [PATCH v3 1/2] cxl/acpi: Fix UAF in the error path Breno Leitao
2023-07-14 9:31 ` [PATCH v3 2/2] cxl/acpi: Do not swallow errors Breno Leitao
2023-07-14 20:50 ` Alison Schofield
2023-07-14 22:33 ` Verma, Vishal L
2023-07-14 20:50 ` [PATCH v3 1/2] cxl/acpi: Fix UAF in the error path Alison Schofield
2023-07-15 3:16 ` Dan Williams [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=64b20f7fc808e_45a62943b@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=leitao@debian.org \
--cc=linux-cxl@vger.kernel.org \
--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