From: "Falkowski, Maciej" <maciej.falkowski@linux.intel.com>
To: Lizhi Hou <lizhi.hou@amd.com>,
ogabbay@kernel.org, quic_jhugo@quicinc.com,
jacek.lawrynowicz@linux.intel.com,
dri-devel@lists.freedesktop.org, dan.carpenter@linaro.org
Cc: linux-kernel@vger.kernel.org, max.zhen@amd.com,
sonal.santan@amd.com, mario.limonciello@amd.com
Subject: Re: [PATCH V1] accel/amdxdna: Fix an integer overflow in aie2_query_ctx_status_array()
Date: Thu, 11 Sep 2025 16:56:07 +0200 [thread overview]
Message-ID: <1d049b9b-e2aa-41f8-9785-9795524b56ef@linux.intel.com> (raw)
In-Reply-To: <20250909154531.3469979-1-lizhi.hou@amd.com>
Reviewed-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>
On 9/9/2025 5:45 PM, Lizhi Hou wrote:
> The unpublished smatch static checker reported a warning.
>
> drivers/accel/amdxdna/aie2_pci.c:904 aie2_query_ctx_status_array()
> warn: potential user controlled sizeof overflow
> 'args->num_element * args->element_size' '1-u32max(user) * 1-u32max(user)'
>
> Even this will not cause a real issue, it is better to put a reasonable
> limitation for element_size and num_element. Add condition to make sure
> the input element_size <= 4K and num_element <= 1K.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/dri-devel/aL56ZCLyl3tLQM1e@stanley.mountain/
> Fixes: 2f509fe6a42c ("accel/amdxdna: Add ioctl DRM_IOCTL_AMDXDNA_GET_ARRAY")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> ---
> drivers/accel/amdxdna/aie2_pci.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c
> index 87c425e3d2b9..6e39c769bb6d 100644
> --- a/drivers/accel/amdxdna/aie2_pci.c
> +++ b/drivers/accel/amdxdna/aie2_pci.c
> @@ -898,6 +898,12 @@ static int aie2_query_ctx_status_array(struct amdxdna_client *client,
>
> drm_WARN_ON(&xdna->ddev, !mutex_is_locked(&xdna->dev_lock));
>
> + if (args->element_size > SZ_4K || args->num_element > SZ_1K) {
> + XDNA_DBG(xdna, "Invalid element size %d or number of element %d",
> + args->element_size, args->num_element);
> + return -EINVAL;
> + }
> +
> array_args.element_size = min(args->element_size,
> sizeof(struct amdxdna_drm_hwctx_entry));
> array_args.buffer = args->buffer;
next prev parent reply other threads:[~2025-09-11 14:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 15:45 [PATCH V1] accel/amdxdna: Fix an integer overflow in aie2_query_ctx_status_array() Lizhi Hou
2025-09-11 14:56 ` Falkowski, Maciej [this message]
2025-09-11 18:34 ` Lizhi Hou
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=1d049b9b-e2aa-41f8-9785-9795524b56ef@linux.intel.com \
--to=maciej.falkowski@linux.intel.com \
--cc=dan.carpenter@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacek.lawrynowicz@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=mario.limonciello@amd.com \
--cc=max.zhen@amd.com \
--cc=ogabbay@kernel.org \
--cc=quic_jhugo@quicinc.com \
--cc=sonal.santan@amd.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