From: "Christian König" <christian.koenig@amd.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>
Cc: Denis Arefev <arefev@swemel.ru>,
Alex Deucher <alexander.deucher@amd.com>,
Simona Vetter <simona@ffwll.ch>,
Andrey Grodzovsky <andrey.grodzovsky@amd.com>,
lvc-project@linuxtesting.org, Chunming Zhou <david1.zhou@amd.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, stable@vger.kernel.org,
David Airlie <airlied@gmail.com>
Subject: Re: [lvc-project] [PATCH] drm/amdgpu: check a user-provided number of BOs in list
Date: Tue, 8 Apr 2025 13:37:17 +0200 [thread overview]
Message-ID: <f8810b13-01d1-4615-b6e2-2e791c48b466@amd.com> (raw)
In-Reply-To: <bmdour3gw4tuwqgvvw764p4ot3nnltqm4e7n3edlbtpfazvp5c@cqe5dwgc66uy>
Am 08.04.25 um 11:39 schrieb Fedor Pchelkin:
> On Tue, 08. Apr 11:26, Christian König wrote:
>> 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.
>> As far as I can see that is already checked by kvmalloc_array().
>>
>> So adding this additional check manually is completely superfluous.
> Note that in->bo_number is of type 'u32' while kvmalloc_array() checks for
> an overflow in 'size_t', usually 64-bit.
>
> So it looks possible to pass some large 32-bit number, then multiply it by
> (comparatively small) in->bo_info_size and still remain in 64-bit bounds.
>
> And later that would likely result in a WARNING in
>
> void *__kvmalloc_node_noprof(DECL_BUCKET_PARAMS(size, b), gfp_t flags, int node)
> {
> ...
> /* Don't even allow crazy sizes */
> if (unlikely(size > INT_MAX)) {
> WARN_ON_ONCE(!(flags & __GFP_NOWARN));
> return NULL;
> }
>
> But the commit description lacks such details, I admit.
Yeah, so what? I'm perfectly aware that this can result in a warning, but that is just not something worth fixing.
Christian.
next prev parent reply other threads:[~2025-04-08 11:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 9:17 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 [this message]
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
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=f8810b13-01d1-4615-b6e2-2e791c48b466@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andrey.grodzovsky@amd.com \
--cc=arefev@swemel.ru \
--cc=david1.zhou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=pchelkin@ispras.ru \
--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
all inboxes | Powered by JetHome®