From: "Christian König" <christian.koenig@amd.com>
To: Denis Arefev <arefev@swemel.ru>,
Alex Deucher <alexander.deucher@amd.com>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
stable@vger.kernel.org
Subject: Re: [PATCH] drm/amdgpu: check a user-provided number of BOs in list
Date: Mon, 14 Apr 2025 11:27:45 +0200 [thread overview]
Message-ID: <aedbcd77-3cb6-48a6-b7ec-b2e5d3d0996c@amd.com> (raw)
In-Reply-To: <20250408091755.10074-1-arefev@swemel.ru>
Coming back to the original patch.
Am 08.04.25 um 11:17 schrieb Denis Arefev:
> The user can set any value to the variable ‘bo_number’, via the ioctl
> command DRM_IOCTL_AMDGPU_BO_LIST. This will affect the arithmetic
> expression ‘in->bo_number * in->bo_info_size’, which is prone to
> overflow. Add a valid value check.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 964d0fbf6301 ("drm/amdgpu: Allow to create BO lists in CS ioctl v3")
> Cc: stable@vger.kernel.org
> Signed-off-by: Denis Arefev <arefev@swemel.ru>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> index 702f6610d024..dd30d2426ff7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> @@ -189,6 +189,9 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in,
> struct drm_amdgpu_bo_list_entry *info;
> int r;
>
> + if (!in->bo_number || in->bo_number > UINT_MAX / info_size)
> + return -EINVAL;
> +
As discussed with Linus the goal here is not to avoid the warning, but rather to apply a reasonable limit.
Since we already use an u16 for the number of BOs in other cases it is probably reasonable to assume that we will never have more than USHRT_MAX number of BOs here as well.
So please change the patch accordingly and hopefully nobody will complain.
Regards,
Christian.
> info = kvmalloc_array(in->bo_number, info_size, GFP_KERNEL);
> if (!info)
> return -ENOMEM;
prev parent reply other threads:[~2025-04-14 9:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 9:17 [PATCH] drm/amdgpu: check a user-provided number of BOs in list Denis Arefev
2025-04-08 9:26 ` Christian König
2025-04-08 9:39 ` [lvc-project] " Fedor Pchelkin
2025-04-08 11:37 ` Christian König
2025-04-08 11:54 ` Fedor Pchelkin
[not found] ` <edc08eb4-63dd-402c-82df-af6898d499a9@amd.com>
2025-04-08 16:07 ` Fedor Pchelkin
2025-04-09 2:39 ` Linus Torvalds
2025-04-09 7:29 ` Christian König
2025-04-09 17:27 ` Linus Torvalds
2025-04-10 9:07 ` Christian König
2025-04-13 11:31 ` Fedor Pchelkin
2025-04-14 9:35 ` Christian König
2025-04-14 9:27 ` Christian König [this message]
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=aedbcd77-3cb6-48a6-b7ec-b2e5d3d0996c@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=arefev@swemel.ru \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=simona@ffwll.ch \
--cc=stable@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