From: Benjamin Cheng <benjamin.cheng@amd.com>
To: Dan Carpenter <error27@gmail.com>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David (Ming Qiang) Wu" <David.Wu3@amd.com>,
amd-gfx@lists.freedesktop.org, "Leo Liu" <leo.liu@amd.com>,
"Ruijing Dong" <ruijing.dong@amd.com>,
"Harshit Mogalapalli" <harshit.m.mogalapalli@oracle.com>
Subject: Re: [PATCH v4 2/5] drm/amdgpu/vce: Prevent partial address patches
Date: Thu, 23 Jul 2026 08:09:27 -0400 [thread overview]
Message-ID: <18c2c72a-4e6d-48ad-910f-924e57ab8a39@amd.com> (raw)
In-Reply-To: <amHzHa_2Cjcu5_7G@stanley.mountain>
On 2026-07-23 06:55, Dan Carpenter wrote:
> [You don't often get email from error27@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On Mon, Mar 30, 2026 at 03:57:54PM -0400, Benjamin Cheng wrote:
>> In the case that only one of lo/hi is valid, the patching could result
>> in a bad address written to in FW.
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
>> index eb4a15db2ef2..efdebd9c0a1f 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
>> @@ -680,6 +680,9 @@ static int amdgpu_vce_cs_reloc(struct amdgpu_cs_parser *p, struct amdgpu_ib *ib,
>> uint64_t addr;
>> int r;
>>
>> + if (lo >= ib->length_dw || hi >= ib->length_dw)
>> + return -EINVAL;
>> +
> I feel like the better fix would be to change the amdgpu_ib_get_value()
> function to return negative for invalid indexes instead of returning 0.
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> 562 static inline u32 amdgpu_ib_get_value(struct amdgpu_ib *ib, uint32_t idx)
> 563 {
> 564 if (idx < ib->length_dw)
> 565 return ib->ptr[idx];
> 566 return 0;
>
> s/return 0/return -EINVAL/
>
> 567 }
>
> amdgpu_vce_validate_bo() has the same issue where invalid lo hi are
> treated as success.
That catches the issue earlier which can save some CPU cycles but amdgpu_vce_validate_bo() is supposed to be resilient to bad addresses since the user could just put bogus addresses into the IB. In this case we just need to prevent a partial address patch, i.e. the hi part of the address got patched with the physical address but the lo part did not (because it's outside the IB).
>
> regards,
> dan carpenter
>
next prev parent reply other threads:[~2026-07-23 12:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 19:57 [PATCH v4 1/5] drm/amdgpu: Add bounds checking to ib_{get,set}_value Benjamin Cheng
2026-03-30 19:57 ` [PATCH v4 2/5] drm/amdgpu/vce: Prevent partial address patches Benjamin Cheng
2026-03-30 20:31 ` Alex Deucher
2026-07-23 10:55 ` Dan Carpenter
2026-07-23 12:09 ` Benjamin Cheng [this message]
2026-03-30 19:57 ` [PATCH v4 3/5] drm/amdgpu/vcn3: Prevent OOB reads when parsing dec msg Benjamin Cheng
2026-03-30 19:57 ` [PATCH v4 4/5] drm/amdgpu/vcn4: " Benjamin Cheng
2026-03-30 19:57 ` [PATCH v4 5/5] drm/amdgpu/vcn4: Prevent OOB reads when parsing IB Benjamin Cheng
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=18c2c72a-4e6d-48ad-910f-924e57ab8a39@amd.com \
--to=benjamin.cheng@amd.com \
--cc=David.Wu3@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=error27@gmail.com \
--cc=harshit.m.mogalapalli@oracle.com \
--cc=leo.liu@amd.com \
--cc=ruijing.dong@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.