drm/amdkfd: add sanity check in svm_range_is_valid

to prevent svm range to be overflow or underflow.

Signed-off-by: Eric Huang <jinhuieric.huang@amd.com>
Reviewed-by: Philip Yang <philip.yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Eric Huang
2026-06-17 14:42:48 -04:00
committed by Alex Deucher
parent 6e03e0b1ab
commit aa7e29cf9a

View File

@@ -3473,7 +3473,13 @@ svm_range_is_valid(struct kfd_process *p, uint64_t start, uint64_t size)
unsigned long start_unchg = start;
start <<= PAGE_SHIFT;
end = start + (size << PAGE_SHIFT);
if (size == 0)
return -EINVAL;
if (check_add_overflow(start, size << PAGE_SHIFT, &end))
return -EOVERFLOW;
do {
vma = vma_lookup(p->mm, start);
if (!vma || (vma->vm_flags & device_vma))