From: Dave Jiang <dave.jiang@intel.com>
To: Samuel Moelius <sam.moelius@trailofbits.com>,
Davidlohr Bueso <dave@stgolabs.net>
Cc: Jonathan Cameron <jic23@kernel.org>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>, Dan Williams <djbw@kernel.org>,
Eric Biggers <ebiggers@kernel.org>,
Alejandro Lucero <alucerop@amd.com>,
"open list:COMPUTE EXPRESS LINK (CXL)"
<linux-cxl@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cxl/test: reject wrapped GET_LOG offsets
Date: Tue, 9 Jun 2026 11:08:15 -0700 [thread overview]
Message-ID: <be106fd7-8a8c-4f29-980e-1b5d9455cab4@intel.com> (raw)
In-Reply-To: <20260605142036.2062347-1-sam.moelius@trailofbits.com>
On 6/5/26 7:20 AM, Samuel Moelius wrote:
> The CXL mock mailbox GET_LOG handler validates the requested CEL slice
> with `offset + length > sizeof(mock_cel)`. Both fields come from the
> userspace CXL_MEM_SEND_COMMAND payload and are 32-bit values, so an
> offset near U32_MAX can wrap the addition to a small value and pass the
> bounds check.
>
> The wrapped request then uses the original large offset as the source
> address for memcpy(), reading far outside the mock CEL array.
>
> Validate the offset first and compare the length against the remaining
> CEL size so the check cannot wrap.
>
> Assisted-by: Codex:gpt-5.5-cyber-preview
> Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> tools/testing/cxl/test/mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> index 271c7ad8cc32..5dc9601a2a7e 100644
> --- a/tools/testing/cxl/test/mem.c
> +++ b/tools/testing/cxl/test/mem.c
> @@ -584,7 +584,7 @@ static int mock_get_log(struct cxl_memdev_state *mds, struct cxl_mbox_cmd *cmd)
> return -EINVAL;
> if (length > cxl_mbox->payload_size)
> return -EINVAL;
> - if (offset + length > sizeof(mock_cel))
> + if (offset > sizeof(mock_cel) || length > sizeof(mock_cel) - offset)
> return -EINVAL;
> if (!uuid_equal(&gl->uuid, &uuid))
> return -EINVAL;
next prev parent reply other threads:[~2026-06-09 18:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 14:20 Samuel Moelius
2026-06-09 18:08 ` Dave Jiang [this message]
2026-06-10 18:01 ` Alison Schofield
2026-06-10 19:03 ` Samuel Moelius
2026-06-28 15:45 ` Samuel Moelius
2026-06-30 9:27 ` Richard Cheng
2026-07-02 0:38 ` Samuel Moelius
2026-07-03 8:39 ` Richard Cheng
2026-07-06 15:10 ` Samuel Moelius
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=be106fd7-8a8c-4f29-980e-1b5d9455cab4@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=alucerop@amd.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=ebiggers@kernel.org \
--cc=ira.weiny@intel.com \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sam.moelius@trailofbits.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®