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/komeda: fix integer overflow in AFBC framebuffer size check

The AFBC framebuffer size validation calculates the minimum required
buffer size by adding the AFBC payload size to the framebuffer offset.
This addition is performed without checking for integer overflow.

If the addition oveflows, the size check may incorrectly succed and
allow userspace to provide an undersized drm_gem_object, potentially
leading to out-of-bounds memory access.

Add usage of check_add_overflow() to safely compute the minimum
required size and reject the framebuffer if an overflow is detected.
This makes the AFBC size validation more robust against malformed.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 65ad2392dd6d ("drm/komeda: Added AFBC support for komeda driver")
Signed-off-by: Alexander Konyukhov <Alexander.Konyukhov@kaspersky.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://lore.kernel.org/r/20260203134907.1587067-1-Alexander.Konyukhov@kaspersky.com

authored by

Alexander Konyukhov and committed by
Liviu Dudau
779ec12c 2bcbc706

+5 -1
+5 -1
drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
··· 4 4 * Author: James.Qian.Wang <james.qian.wang@arm.com> 5 5 * 6 6 */ 7 + #include <linux/overflow.h> 8 + 7 9 #include <drm/drm_device.h> 8 10 #include <drm/drm_fb_dma_helper.h> 9 11 #include <drm/drm_gem.h> ··· 95 93 kfb->afbc_size = kfb->offset_payload + n_blocks * 96 94 ALIGN(bpp * AFBC_SUPERBLK_PIXELS / 8, 97 95 AFBC_SUPERBLK_ALIGNMENT); 98 - min_size = kfb->afbc_size + fb->offsets[0]; 96 + if (check_add_overflow(kfb->afbc_size, fb->offsets[0], &min_size)) { 97 + goto check_failed; 98 + } 99 99 if (min_size > obj->size) { 100 100 DRM_DEBUG_KMS("afbc size check failed, obj_size: 0x%zx. min_size 0x%llx.\n", 101 101 obj->size, min_size);