All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: "Lin Huiyi" <xinghui79@qq.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/amdgpu: Fix stack buffer overflow in UALink vPod integrity check
Date: Tue, 1 Dec 2026 11:14:01 +0530	[thread overview]
Message-ID: <da24ee68-2fc5-42c4-9bef-a8ab4d2b5480@amd.com> (raw)
In-Reply-To: <tencent_446CA55358A7423ABD16D050C24164FA6B0A@qq.com>



On 01-Dec-26 10:32 AM, Lin Huiyi wrote:
> __check_local_vpod_integrity() collects the accelerator IDs of all local
> GPUs that belong to the vPod into a fixed-size local_accels[] array.  The
> loop is bounded by mgpu_info.num_gpu (up to MAX_GPU_INSTANCE, i.e. 64)
> and only filters peers by vPod membership, so every matching peer is
> appended unconditionally:
> 
> 		local_accels[n_local_accels++] = accel_id;
> 
> There is no check that n_local_accels stays below
> AMDGPU_UALINK_LOCAL_ACCELS_MAX, so a pod with more local GPUs than the
> array can hold writes past the end of a stack array.  The oversized
> count is then propagated to peer_info->n_local_accels, and the
> downstream loops in amdgpu_ualink_is_local_accel() and
> activate_local_vpod() walk past the end of the peer's local_accels[]
> array as well.
> 
> Reject a pod that reports more local peers than the array can hold, and
> only copy the entries that were filled in.
> 
> Changes since v1:
> - Keep AMDGPU_UALINK_LOCAL_ACCELS_MAX at 8 as the current limit is
>    sufficient (Lijo Lazar).
> 
> Fixes: 0e8eb0dcea51 ("drm/amdgpu: Assign accel state based on ASP config")
> Signed-off-by: Lin Huiyi <xinghui79@qq.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> index d025b4183b..b4fac5ecab 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> @@ -1243,6 +1243,12 @@ static int __check_local_vpod_integrity(struct amdgpu_device *adev)
>   				 accel_id);
>   			return -EINVAL;
>   		}
> +		if (n_local_accels >= AMDGPU_UALINK_LOCAL_ACCELS_MAX) {
> +			dev_warn(adev->dev,
> +				 "UALINK: integrity fail: too many local vpod peers: %u (max %u)\n",
> +				 n_local_accels + 1, AMDGPU_UALINK_LOCAL_ACCELS_MAX);
> +			return -EINVAL;
> +		}

Missed this earlier. This check could be a generic one done outside the 
loop

unlikely (mgpu_info.num_gpu >= AMDGPU_UALINK_LOCAL_ACCELS_MAX)


Thanks,
Lijo

>   		local_accels[n_local_accels++] = accel_id;
>   	}
>   
> @@ -1257,7 +1263,7 @@ static int __check_local_vpod_integrity(struct amdgpu_device *adev)
>   
>   		peer_info->n_local_accels = n_local_accels;
>   		memcpy(peer_info->local_accels, local_accels,
> -		       sizeof(local_accels));
> +		       n_local_accels * sizeof(*local_accels));
>   	}
>   
>   	return 0;


  reply	other threads:[~2026-12-01  5:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 14:14 [PATCH] drm/amdgpu: Fix stack buffer overflow in UALink vPod integrity check Lin Huiyi
2026-12-01  4:22 ` Lazar, Lijo
2026-12-01  4:30   ` Lazar, Lijo
2026-12-01  5:02 ` [PATCH v2] " Lin Huiyi
2026-12-01  5:44   ` Lazar, Lijo [this message]
2026-12-01  5:46     ` Lazar, Lijo
2026-12-01  5:52   ` [PATCH v3] " Lin Huiyi
2026-12-01  6:06     ` sashiko-bot
2026-12-01  6:17     ` [PATCH v4] " Lin Huiyi
2026-12-01  7:57       ` Lazar, Lijo
2026-12-01  8:21       ` [PATCH v5] " Lin Huiyi
2026-12-01  8:39         ` sashiko-bot

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=da24ee68-2fc5-42c4-9bef-a8ab4d2b5480@amd.com \
    --to=lijo.lazar@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=simona@ffwll.ch \
    --cc=xinghui79@qq.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.