mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Nikita Zhandarovich <n.zhandarovich@fintech.ru>,
	Alex Deucher <alexander.deucher@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/radeon/r600_cs: Fix possible int overflows in r600_cs_check_reg()
Date: Wed, 29 Nov 2023 16:47:03 +0100	[thread overview]
Message-ID: <6a26b0c9-cbea-4ca2-bc16-79ed53e3a6fe@amd.com> (raw)
In-Reply-To: <20231129152230.7931-1-n.zhandarovich@fintech.ru>

Am 29.11.23 um 16:22 schrieb Nikita Zhandarovich:
> While improbable, there may be a chance of hitting integer
> overflow when the result of radeon_get_ib_value() gets shifted
> left.
>
> Avoid it by casting one of the operands to larger data type (u64).
>
> Found by Linux Verification Center (linuxtesting.org) with static
> analysis tool SVACE.

Well IIRC cb_color_bo_offset is just 32bits anyway, so this doesn't 
change anything.

Regards,
Christian.

>
> Fixes: 1729dd33d20b ("drm/radeon/kms: r600 CS parser fixes")
> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
> ---
>   drivers/gpu/drm/radeon/r600_cs.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
> index 638f861af80f..6cf54a747749 100644
> --- a/drivers/gpu/drm/radeon/r600_cs.c
> +++ b/drivers/gpu/drm/radeon/r600_cs.c
> @@ -1275,7 +1275,7 @@ static int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
>   			return -EINVAL;
>   		}
>   		tmp = (reg - CB_COLOR0_BASE) / 4;
> -		track->cb_color_bo_offset[tmp] = radeon_get_ib_value(p, idx) << 8;
> +		track->cb_color_bo_offset[tmp] = (u64)radeon_get_ib_value(p, idx) << 8;
>   		ib[idx] += (u32)((reloc->gpu_offset >> 8) & 0xffffffff);
>   		track->cb_color_base_last[tmp] = ib[idx];
>   		track->cb_color_bo[tmp] = reloc->robj;
> @@ -1302,7 +1302,7 @@ static int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
>   					"0x%04X\n", reg);
>   			return -EINVAL;
>   		}
> -		track->htile_offset = radeon_get_ib_value(p, idx) << 8;
> +		track->htile_offset = (u64)radeon_get_ib_value(p, idx) << 8;
>   		ib[idx] += (u32)((reloc->gpu_offset >> 8) & 0xffffffff);
>   		track->htile_bo = reloc->robj;
>   		track->db_dirty = true;


  reply	other threads:[~2023-11-29 15:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 15:22 Nikita Zhandarovich
2023-11-29 15:47 ` Christian König [this message]
2023-11-29 16:03   ` Alex Deucher
2023-11-30  6:41     ` Christian König
2023-11-30 17:06 ` Alex Deucher

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=6a26b0c9-cbea-4ca2-bc16-79ed53e3a6fe@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=n.zhandarovich@fintech.ru \
    /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®