Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/vc4: Protect madv read in vc4_gem_object_mmap() with madv_lock

The mmap callback reads bo->madv without holding madv_lock, racing with
concurrent DRM_IOCTL_VC4_GEM_MADVISE calls that modify the field under
the same lock. Add the missing locking to prevent the data race.

Fixes: b9f19259b84d ("drm/vc4: Add the DRM_IOCTL_VC4_GEM_MADVISE ioctl")
Reviewed-by: Melissa Wen <mwen@igalia.com>
Link: https://patch.msgid.link/20260330-vc4-misc-fixes-v1-4-92defc940a29@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>

+3
+3
drivers/gpu/drm/vc4/vc4_bo.c
··· 738 738 return -EINVAL; 739 739 } 740 740 741 + mutex_lock(&bo->madv_lock); 741 742 if (bo->madv != VC4_MADV_WILLNEED) { 742 743 DRM_DEBUG("mmapping of %s BO not allowed\n", 743 744 bo->madv == VC4_MADV_DONTNEED ? 744 745 "purgeable" : "purged"); 746 + mutex_unlock(&bo->madv_lock); 745 747 return -EINVAL; 746 748 } 749 + mutex_unlock(&bo->madv_lock); 747 750 748 751 return drm_gem_dma_mmap(&bo->base, vma); 749 752 }