From: Dave Jiang <dave.jiang@intel.com>
To: Richard Cheng <icheng@nvidia.com>,
dave@stgolabs.net, jic23@kernel.org, alison.schofield@intel.com,
vishal.l.verma@intel.com, djbw@kernel.org,
danwilliams@nvidia.com
Cc: iweiny@kernel.org, ming.li@zohomail.com, kobak@nvidia.com,
kaihengf@nvidia.com, kees@kernel.org, newtonl@nvidia.com,
kristinc@nvidia.com, mochs@nvidia.com, linux-cxl@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] cxl/features: Clamp Get Feature output size to the remaining buffer
Date: Tue, 14 Jul 2026 11:06:49 -0700 [thread overview]
Message-ID: <afcb4966-88c3-4462-b1f2-5e63dfdabd81@intel.com> (raw)
In-Reply-To: <20260626104102.53892-4-icheng@nvidia.com>
On 6/26/26 3:41 AM, Richard Cheng wrote:
> cxl_get_feature() reads a feature in a loop but passes a fixed size_out
> as the output capacity every iteration. On the last partial iteration
> the buffer has less room left, so a device that returns more than asked
> can overflow feat_out.
>
> Use the per-iter size data_to_rd_size, which already tracks the
> remaining room, as the output capacity.
>
> Fixes: 5e5ac21f629d ("cxl/mbox: Add GET_FEATURE mailbox command")
> Signed-off-by: Richard Cheng <icheng@nvidia.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> Changelog:
>
> v2 -> v3:
> - New patch.
>
> drivers/cxl/core/features.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c
> index ed18ccb5e236..e52371f87300 100644
> --- a/drivers/cxl/core/features.c
> +++ b/drivers/cxl/core/features.c
> @@ -225,7 +225,7 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
> void *feat_out, size_t feat_out_size, u16 offset,
> u16 *return_code)
> {
> - size_t data_to_rd_size, size_out;
> + size_t data_to_rd_size;
> struct cxl_mbox_get_feat_in pi;
> struct cxl_mbox_cmd mbox_cmd;
> size_t data_rcvd_size = 0;
> @@ -237,7 +237,6 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
> if (!feat_out || !feat_out_size)
> return 0;
>
> - size_out = min(feat_out_size, cxl_mbox->payload_size);
> uuid_copy(&pi.uuid, feat_uuid);
> pi.selection = selection;
> do {
> @@ -250,7 +249,7 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
> .opcode = CXL_MBOX_OP_GET_FEATURE,
> .size_in = sizeof(pi),
> .payload_in = &pi,
> - .size_out = size_out,
> + .size_out = data_to_rd_size,
> .payload_out = feat_out + data_rcvd_size,
> .min_out = data_to_rd_size,
> };
next prev parent reply other threads:[~2026-07-14 18:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 10:40 [PATCH v3 0/3] cxl/features: Bounds-check the fwctl feature commands Richard Cheng
2026-06-26 10:41 ` [PATCH v3 1/3] cxl/features: Reject Get Feature count larger than the output buffer Richard Cheng
2026-07-14 19:29 ` Alison Schofield
2026-06-26 10:41 ` [PATCH v3 2/3] cxl/features: Reject Set Features output buffer smaller than the header Richard Cheng
2026-07-14 18:05 ` Dave Jiang
2026-07-14 19:30 ` Alison Schofield
2026-06-26 10:41 ` [PATCH v3 3/3] cxl/features: Clamp Get Feature output size to the remaining buffer Richard Cheng
2026-07-14 18:06 ` Dave Jiang [this message]
2026-07-14 19:31 ` Alison Schofield
2026-07-13 7:22 ` [PATCH v3 0/3] cxl/features: Bounds-check the fwctl feature commands Richard Cheng
2026-07-14 21:01 ` 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=afcb4966-88c3-4462-b1f2-5e63dfdabd81@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=danwilliams@nvidia.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=icheng@nvidia.com \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=kaihengf@nvidia.com \
--cc=kees@kernel.org \
--cc=kobak@nvidia.com \
--cc=kristinc@nvidia.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=mochs@nvidia.com \
--cc=newtonl@nvidia.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