Skip to content

Commit 178e31c

Browse files
matt-auldtursulin
authored andcommitted
drm/i915/userptr: restore probe_range behaviour
The conversion looks harmless, however the addr value is updated inside the loop with the previous vm_end, which then incorrectly leads to for_each_vma_range() iterating over stuff outside the range we care about. Fix this by storing the end value separately. Also fix the case where the range doesn't intersect with any vma, or if the vma itself doesn't extend the entire range, which must mean we have hole at the end. Both should result in an error, as per the previous behaviour. v2: Fix the cases where the range is empty, or if there's a hole at the end of the range Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7247 Testcase: igt@gem_userptr_blits@probe Fixes: f683b9d ("i915: use the VMA iterator") Reported-by: kernel test robot <[email protected]> Signed-off-by: Matthew Auld <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Liam R. Howlett <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Yu Zhao <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 6f7de35) Signed-off-by: Tvrtko Ursulin <[email protected]>
1 parent 19b1681 commit 178e31c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpu/drm/i915/gem/i915_gem_userptr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,10 @@ probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
428428
{
429429
VMA_ITERATOR(vmi, mm, addr);
430430
struct vm_area_struct *vma;
431+
unsigned long end = addr + len;
431432

432433
mmap_read_lock(mm);
433-
for_each_vma_range(vmi, vma, addr + len) {
434+
for_each_vma_range(vmi, vma, end) {
434435
/* Check for holes, note that we also update the addr below */
435436
if (vma->vm_start > addr)
436437
break;
@@ -442,7 +443,7 @@ probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
442443
}
443444
mmap_read_unlock(mm);
444445

445-
if (vma)
446+
if (vma || addr < end)
446447
return -EFAULT;
447448
return 0;
448449
}

0 commit comments

Comments
 (0)