From: Alison Schofield <alison.schofield@intel.com>
To: Guixin Liu <kanie@linux.alibaba.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
Jonathan Cameron <jic23@kernel.org>,
Dave Jiang <dave.jiang@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dan Williams <djbw@kernel.org>, Ira Weiny <iweiny@kernel.org>,
Li Ming <ming.li@zohomail.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v3] cxl/core: Fix dport use-after-free via the einj_inject debugfs file
Date: Fri, 28 Aug 2026 17:31:26 -0700 [thread overview]
Message-ID: <apIoXt4WQiMdVef_@aschofie-mobl2.lan> (raw)
In-Reply-To: <20260828074752.3336779-1-kanie@linux.alibaba.com>
On Fri, Aug 28, 2026 at 03:47:52PM +0800, Guixin Liu wrote:
> The per-dport einj_inject debugfs file retains a pointer to the
> 'struct cxl_dport', but its lifetime is not tied to the dport. Unbinding
> the dport host frees the dport and leaves einj_inject behind, so writing
> the file dereferences freed memory:
>
> BUG: KASAN: slab-use-after-free in cxl_einj_inject+0xa1/0xf0 [cxl_core]
> Read of size 1 at addr ffff88810880ac90 by task bash/1690
> cxl_einj_inject+0xa1/0xf0 [cxl_core]
> debugfs_attr_write+0x61/0xb0
> full_proxy_write+0xfc/0x1c0
> vfs_write+0x1d4/0xe60
> Allocated by task 213:
> __devm_cxl_add_dport+0x1e1/0x14d0 [cxl_core]
> cxl_port_add_dport+0xd6/0x200 [cxl_port]
> Freed by task 1622:
> release_nodes+0xfa/0x2c0
> devres_release_all+0x113/0x1a0
> device_unbind_cleanup+0x76/0x260
> unbind_store+0xde/0x100
>
> The stale directory also prevents recreation on rebind.
>
> Remove the per-dport debugfs directory when the dport host is released.
>
> Found by code inspection, then reproduced on a QEMU CXL topology with
> KASAN (the einj_cxl_is_initialized() guard had to be forced open, as
> QEMU emits no EINJ table). Unpatched, writing the leftover file after
> unbind gives the splat above, and rebind hits "already exists in
> 'cxl'". Patched, the directory goes away with the dport and rebind
> recreates a working einj_inject.
>
> Fixes: 8039804cfa73 ("cxl/core: Add CXL EINJ debugfs files")
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> Reviewed-by: Richard Cheng <icheng@nvidia.com>
> Reviewed-by: Li Ming <ming.li@zohomail.com>
Thanks for the changelog updatges Guixin.
DaveJ - KASAN trace could be left out upon applying.
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
prev parent reply other threads:[~2026-08-29 0:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 7:47 [PATCH v3] cxl/core: Fix dport use-after-free via the einj_inject debugfs file Guixin Liu
2026-08-29 0:31 ` Alison Schofield [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=apIoXt4WQiMdVef_@aschofie-mobl2.lan \
--to=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=kanie@linux.alibaba.com \
--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