dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aldo Ariel Panzardo" <qwe.aldo@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: fix ATOM parameter space index bounds check
Date: Wed, 23 Sep 2026 16:22:26 +0000	[thread overview]
Message-ID: <20260923162226.D0C081F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260923161252.1363895-1-qwe.aldo@gmail.com>

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 <qwe.aldo@gmail.com>

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/20260923163157.1354872-1-qwe.aldo@gmail.com?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/20260923161252.1363895-1-qwe.aldo@gmail.com?part=1

      reply	other threads:[~2026-09-23 16:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 16:12 [PATCH] drm/amdgpu: fix ATOM parameter space index bounds check Aldo Ariel Panzardo
2026-09-23 16:22 ` sashiko-bot [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=20260923162226.D0C081F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=qwe.aldo@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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