Linux CXL
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Dan Williams <djbw@kernel.org>, linux-cxl@vger.kernel.org
Cc: alison.schofield@intel.com
Subject: Re: [PATCH 1/2] cxl/fwctl: Fix __fortify_panic
Date: Tue, 19 May 2026 16:10:40 -0700	[thread overview]
Message-ID: <43d46939-dd16-46bd-9447-a4bce5941f5e@intel.com> (raw)
In-Reply-To: <20260519221204.1517773-2-djbw@kernel.org>



On 5/19/26 3:12 PM, Dan Williams wrote:
> Fix a runtime assertion in cxlctl_get_supported_features(). Fortify
> complains that it is potentially overflowing the entries array per
> __counted_by_le(num_entries). Quiet the false positive by initializing
> @num_entries earlier.
> 
>  memcpy: detected buffer overflow: 48 byte write of buffer size 0
>  WARNING: lib/string_helpers.c:1036 at __fortify_report+0x4d/0xa0, CPU#7: fwctl/1398
>  RIP: 0010:__fortify_report+0x50/0xa0
>  Call Trace:
>   __fortify_panic+0xd/0xf
>   cxlctl_get_supported_features.cold+0x23/0x35 [cxl_core]
> 
> Fixes: 4d1c09cef2c2 ("cxl: Add support for fwctl RPC command to enable CXL feature commands")
> Signed-off-by: Dan Williams <djbw@kernel.org>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>


> ---
>  drivers/cxl/core/features.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c
> index 3435db9ea6b1..85185af46b72 100644
> --- a/drivers/cxl/core/features.c
> +++ b/drivers/cxl/core/features.c
> @@ -423,6 +423,7 @@ static void *cxlctl_get_supported_features(struct cxl_features_state *cxlfs,
>  
>  	rpc_out->size = struct_size(feat_out, ents, requested);
>  	feat_out = &rpc_out->get_sup_feats_out;
> +	feat_out->num_entries = cpu_to_le16(requested);
>  
>  	for (i = start, pos = &feat_out->ents[0];
>  	     i < cxlfs->entries->num_features; i++, pos++) {
> @@ -444,7 +445,6 @@ static void *cxlctl_get_supported_features(struct cxl_features_state *cxlfs,
>  		}
>  	}
>  
> -	feat_out->num_entries = cpu_to_le16(requested);
>  	feat_out->supported_feats = cpu_to_le16(cxlfs->entries->num_features);
>  	rpc_out->retval = CXL_MBOX_CMD_RC_SUCCESS;
>  	*out_len = out_size;


  reply	other threads:[~2026-05-19 23:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19 22:12 [PATCH 0/2] cxl: fortify string fixups Dan Williams
2026-05-19 22:12 ` [PATCH 1/2] cxl/fwctl: Fix __fortify_panic Dan Williams
2026-05-19 23:10   ` Dave Jiang [this message]
2026-05-20  2:51   ` Alison Schofield
2026-05-19 22:12 ` [PATCH 2/2] cxl/test: " Dan Williams
2026-05-19 23:13   ` Dave Jiang
2026-05-20  2:50   ` Alison Schofield
2026-05-20  2:55 ` [PATCH 0/2] cxl: fortify string fixups Alison Schofield
2026-06-02 16:20 ` 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=43d46939-dd16-46bd-9447-a4bce5941f5e@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=djbw@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    /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