Skip to content

Commit 8165e8b

Browse files
Alexander Konyukhovgregkh
authored andcommitted
drm/komeda: fix integer overflow in AFBC framebuffer size check
[ Upstream commit 779ec12 ] 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: 65ad239 ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 183128d commit 8165e8b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Author: James.Qian.Wang <james.qian.wang@arm.com>
55
*
66
*/
7+
#include <linux/overflow.h>
8+
79
#include <drm/drm_device.h>
810
#include <drm/drm_fb_dma_helper.h>
911
#include <drm/drm_gem.h>
@@ -92,7 +94,9 @@ komeda_fb_afbc_size_check(struct komeda_fb *kfb, struct drm_file *file,
9294
kfb->afbc_size = kfb->offset_payload + n_blocks *
9395
ALIGN(bpp * AFBC_SUPERBLK_PIXELS / 8,
9496
AFBC_SUPERBLK_ALIGNMENT);
95-
min_size = kfb->afbc_size + fb->offsets[0];
97+
if (check_add_overflow(kfb->afbc_size, fb->offsets[0], &min_size)) {
98+
goto check_failed;
99+
}
96100
if (min_size > obj->size) {
97101
DRM_DEBUG_KMS("afbc size check failed, obj_size: 0x%zx. min_size 0x%llx.\n",
98102
obj->size, min_size);

0 commit comments

Comments
 (0)