Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] drm/amdgpu: confusing log message for ATOM PS index out of range
--

commit dd873e6794eea339db29a3fa2da08121624e1439
Author: Aldo Ariel Panzardo <[email protected]>

drm/amdgpu: fix ATOM parameter space index bounds check

This commit divides ctx->ps_size by 4 in atom_get_src_int() and
atom_put_dst() to prevent out-of-bounds dword accesses into the parameter
buffer.

Closes: 
https://sashiko.dev/#/patchset/[email protected]?part=1

> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 1a599d5cf6a5c..b86ed700c5f87 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -232,7 +232,7 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, 
> uint8_t attr,
>               (*ptr)++;
>               /* get_unaligned_le32 avoids unaligned accesses from atombios
>                * tables, noticed on a DEC Alpha. */
> -             if (idx < ctx->ps_size)
> +             if (idx < ctx->ps_size / 4)
>                       val = get_unaligned_le32((u32 *)&ctx->ps[idx]);
>               else
>                       pr_info("PS index out of range: %i > %i\n", idx, 
> ctx->ps_size);

[Severity: Low]
Does this print a mathematically confusing log message? Since the check now
validates idx against ctx->ps_size / 4, if idx is between ctx->ps_size / 4
and ctx->ps_size - 1, the log could print something like "5 > 16". Should
we also divide ctx->ps_size by 4 in the pr_info() statement to match the
dword indexing?

> @@ -510,7 +510,7 @@ static void atom_put_dst(atom_exec_context *ctx, int arg, 
> uint8_t attr,
>               idx = U8(*ptr);
>               (*ptr)++;
>               DEBUG("PS[0x%02X]", idx);
> -             if (idx >= ctx->ps_size) {
> +             if (idx >= ctx->ps_size / 4) {
>                       pr_info("PS index out of range: %i > %i\n", idx, 
> ctx->ps_size);

[Severity: Low]
Similarly, does this print the byte size instead of the dword size? Since the
out of bounds check now uses ctx->ps_size / 4, this could also print
contradictory statements when the error condition is hit.

>                       return;
>               }

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to