From: sashiko-bot@kernel.org
To: "Lin Huiyi" <xinghui79@qq.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/amdgpu: Fix stack buffer overflow in UALink vPod integrity check
Date: Tue, 01 Dec 2026 06:06:15 +0000 [thread overview]
Message-ID: <sashiko-outbox-242674@kernel.org> (raw)
In-Reply-To: <tencent_90933440D34FACA121875E13683CE1BC3309@qq.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/amdgpu: flawed mgpu_info.num_gpu check in
__check_local_vpod_integrity()
--
commit 1d7eca73ed4f664c879aa6472e418261effb5a74
Author: Lin Huiyi <xinghui79@qq.com>
drm/amdgpu: Fix stack buffer overflow in UALink vPod integrity check
This commit adds a check on mgpu_info.num_gpu against
AMDGPU_UALINK_LOCAL_ACCELS_MAX in __check_local_vpod_integrity() and limits
the memcpy() length to the populated entries in local_accels[].
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> index fa4c3d27d2720..f697dde5a0d4d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> @@ -1162,6 +1162,17 @@ static int __check_local_vpod_integrity(struct amdgpu_device *adev)
> __set_bit(info->ppod.accel_id, local_accel_ids);
> local_accels[n_local_accels++] = info->ppod.accel_id;
>
> + /*
> + * local_accels[] holds the local GPU itself plus one entry per peer,
> + * so more GPUs than AMDGPU_UALINK_LOCAL_ACCELS_MAX cannot fit.
> + */
> + if (unlikely(mgpu_info.num_gpu > AMDGPU_UALINK_LOCAL_ACCELS_MAX)) {
> + dev_warn(adev->dev,
> + "UALINK: integrity fail: too many local GPUs: %u (max %u)\n",
> + mgpu_info.num_gpu, AMDGPU_UALINK_LOCAL_ACCELS_MAX);
> + return -EINVAL;
> + }
> +
> for (i = 0; i < mgpu_info.num_gpu; i++) {
> peer_adev = mgpu_info.gpu_ins[i].adev;
> if (peer_adev == adev || !peer_adev->ualink.info)
[Severity: Medium]
Should the bounds check test n_local_accels against
AMDGPU_UALINK_LOCAL_ACCELS_MAX inside the loop after filtering for vPod
membership, instead of checking mgpu_info.num_gpu up front?
mgpu_info.num_gpu counts all registered amdgpu instances in the system,
whereas the loop skips non-UALink GPUs (!peer_adev->ualink.info) and GPUs
in other vPods (!test_bit(accel_id, info->vpod.active_accel_bits)).
Checking mgpu_info.num_gpu > AMDGPU_UALINK_LOCAL_ACCELS_MAX before
filtering rejects valid vPods of 8 or fewer GPUs on systems that also have
an integrated or non-UALink GPU, or that partition more than 8 local GPUs
across multiple vPods.
In addition, local_accels[0] is already populated with info->ppod.accel_id
before the loop (n_local_accels == 1). Allowing mgpu_info.num_gpu == 8
assumes adev itself is in mgpu_info.gpu_ins[] and will be skipped by
peer_adev == adev. However, amdgpu_unregister_gpu_instance() removes adev
from mgpu_info.gpu_ins[] before interrupts are disabled in
amdgpu_driver_unload_kms() and during reset in
amdgpu_device_halt_activities(). If __check_local_vpod_integrity() runs
from amdgpu_ualink_config_update_handler() while adev is not in
mgpu_info.gpu_ins[] and 8 matching peers remain, n_local_accels reaches 9
and writes one element past the end of local_accels[] and
peer_info->local_accels[].
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_90933440D34FACA121875E13683CE1BC3309@qq.com?part=1
next prev parent reply other threads:[~2026-12-01 6:06 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
2026-12-01 5:46 ` Lazar, Lijo
2026-12-01 5:52 ` [PATCH v3] " Lin Huiyi
2026-12-01 6:06 ` sashiko-bot [this message]
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=sashiko-outbox-242674@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox