From: sashiko-bot@kernel.org
To: "Daniel Huang" <danielhu@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdkfd: disable SVM when the GPUVM cannot cover CPU addresses
Date: Fri, 16 Oct 2026 07:08:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-173901@kernel.org> (raw)
In-Reply-To: <20261016145129.69645-1-danielhu@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] amdgpu: out-of-bounds array access due to flawed KFD SVM bounds check
--
commit f15cd1b71660722b40bc92fadadb46cc7210b7fd
Author: Daniel Huang <danielhu@amd.com>
Date: Fri Oct 16 14:51:29 2026 +0000
drm/amdkfd: disable SVM when the GPUVM cannot cover CPU addresses
KFD SVM maps memory in GPUVM at the same virtual address used by
the CPU. However, svm_range_map_to_gpu() passes the corresponding
PFNs to amdgpu_vm_update_range() without checking them against
vm_manager.max_pfn.
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.h b/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
> index c7d7adae4476b..6235ce0f988ea 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
> @@ -203,11 +203,25 @@ struct kfd_process_device *
> svm_range_get_pdd_by_node(struct svm_range *prange, struct kfd_node *node);
> void svm_range_list_lock_and_flush_work(struct svm_range_list *svms, struct mm_struct *mm);
>
> +/*
> + * SVM uses CPU virtual addresses for GPU mappings. Disable SVM if the GPUVM
> + * address range cannot cover the required CPU address range.
> + *
> + * The parameter must be named adev since AMDGPU_GMC_HOLE_START references
> + * adev->vm_manager.max_level.
> + */
> +static inline bool kfd_svm_vm_covers_user_va(struct amdgpu_device *adev)
> +{
> + return (adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT) >=
> + AMDGPU_GMC_HOLE_START;
[Severity: High]
Does this check erroneously rely on the GPU-dependent hole start instead of
the CPU's actual maximum user virtual address?
AMDGPU_GMC_HOLE_START is defined based on the GPU's capabilities:
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h:
#define AMDGPU_GMC_HOLE_START (adev->vm_manager.max_level == 4 ?\
0x0100000000000000ULL : 0x0000800000000000ULL)
On a system with a 57-bit (5-level) CPU and a 48-bit (4-level) GPU, this
comparison evaluates to true, keeping SVM enabled. A malicious userspace
program could then map a valid CPU address above 48 bits and pass it to
KFD SVM.
This would result in svm_range_validate_and_map() passing the unvalidated
address to amdgpu_vm_update_range(), leading to an out-of-bounds access in
amdgpu_vm_pt_descendant():
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c:amdgpu_vm_pt_descendant() {
...
idx = (cursor->pfn >> shift) & mask;
cursor->parent = cursor->entry;
cursor->entry = &to_amdgpu_bo_vm(cursor->entry->bo)->entries[idx];
...
}
Should this check use a CPU-specific limit like TASK_SIZE_MAX to ensure SVM
is safely disabled when the GPU cannot cover the CPU's address space?
> +}
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016145129.69645-1-danielhu@amd.com?part=1
next prev parent reply other threads:[~2026-10-16 7:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 14:51 [PATCH] drm/amdkfd: disable SVM when the GPUVM cannot cover CPU addresses Daniel Huang
2026-10-16 7:08 ` sashiko-bot [this message]
2026-10-16 9:09 ` Christian König
2026-10-16 20:02 ` Felix Kuehling
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-173901@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=danielhu@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--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 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.