From: Jonathan Cameron <jic23@kernel.org>
To: Dave Jiang <dave.jiang@intel.com>
Cc: Ashok Raj <ashok.raj@oss.qualcomm.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Alison Schofield <alison.schofield@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>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [RESEND PATCH] cxl/features: Ensure that count is set before access to end[] __counted_by()
Date: Fri, 11 Sep 2026 23:44:57 +0100 [thread overview]
Message-ID: <20260911234457.7be8f66d@jic23-hlaptop> (raw)
In-Reply-To: <6a5c975c-764f-4af7-8aa3-9dea94ad603f@intel.com>
On Fri, 11 Sep 2026 14:58:29 -0700
Dave Jiang <dave.jiang@intel.com> wrote:
Typo in patch title end/ent[]
(might be mine given I suggested a title to Ashok during internal review!)
Hopefully Dave won't mind fixing that whilst picking it up.
> On 9/11/26 2:53 PM, Ashok Raj wrote:
> > get_supported_features() assigns entries->num_features only after the
> > memcpy() loop that fills entries->ent[] has already run. Since ent[]
> > is __counted_by(num_features), the compiler's bounds instrumentation
> > sees a 0-length array during that loop and FORTIFY_SOURCE trips on
> > the memcpy. Set @num_features right after allocation, before any
> > write into ent[], so the bound is correct for the whole lifetime of
> > the array.
> >
> > This was found via a fortify panic:
> >
> > memcpy: detected buffer overflow: 384 byte write of buffer size 0
> > WARNING: lib/string_helpers.c:1035 at __fortify_report+0x54/0xa0
> > kernel BUG at lib/string_helpers.c:1043!
> > Call trace:
> > __fortify_panic+0x10/0x18
> > get_supported_features.isra.0+0x4a0/0x4d0 [cxl_core]
> > devm_cxl_setup_features+0x84/0x120 [cxl_core]
> > cxl_pci_probe+0x254/0x5e0 [cxl_pci]
> >
> > Same class of bug, same fix shape as commit 6c9d2e87df40
> > ("cxl/fwctl: Fix __fortify_panic"), which fixed the analogous issue
> > in cxlctl_get_supported_features() but missed this one.
> >
> > Fixes: f0e6a2329bf9 ("cxl: Add Get Supported Features command for kernel usage")
> > Signed-off-by: Ashok Raj <ashok.raj@oss.qualcomm.com>
>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
next prev parent reply other threads:[~2026-09-11 22:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 21:53 Ashok Raj
2026-09-11 21:58 ` Dave Jiang
2026-09-11 22:44 ` Jonathan Cameron [this message]
2026-09-11 23:59 ` 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=20260911234457.7be8f66d@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=alison.schofield@intel.com \
--cc=ashok.raj@oss.qualcomm.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=gustavoars@kernel.org \
--cc=iweiny@kernel.org \
--cc=kees@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®