From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C838D1D90DD for ; Wed, 4 Feb 2026 13:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770211571; cv=none; b=IS+B1bXSqF5tR0Hj2XJEyOw3P64AHwpONfjebMMcBof/iANC0tsbLRu9CpF778wdMBRowNadjE9bboXZVibPFZ7TY12lxk4csUdBG3kr4DE/CJsMPhoaO/YLqoMprWmwFfBBOUSnNKL3KMY7HoXBw0iQAJLaN+/SNCRZ0JSQl2s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770211571; c=relaxed/simple; bh=kyUbeb/L/Y0wt1ucQFoxZf097407zM10TNZ0C4au+3Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dw3/IlKN90gKqN6N6FDoln5y/49YDFE3AVHo+X1Qd748S/3XVtyCuqDS/Y1RyBsuMnff7OaWkb6euUye34iNLtIvsFWJlY/EU9/YQm0/gakDajQUuoSwFU3hKmJvwMvuOEVN+vJeh6Ax7jtyEB5nLMZXhsuPw9HD73Rka3th3qY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 876B7339 for ; Wed, 4 Feb 2026 05:26:03 -0800 (PST) Received: from [192.168.0.1] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B37723F778 for ; Wed, 4 Feb 2026 05:26:09 -0800 (PST) Date: Wed, 4 Feb 2026 13:24:30 +0000 From: Liviu Dudau To: Brian Starkey Cc: Alexander Konyukhov , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, nd@arm.com Subject: Re: [PATCH] drm/komeda: fix integer overflow in AFBC framebuffer size check Message-ID: References: <20260203134907.1587067-1-Alexander.Konyukhov@kaspersky.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Tue, Feb 03, 2026 at 09:43:12PM +0000, Brian Starkey wrote: > Hi Alexander, > > On Tue, Feb 03, 2026 at 04:48:46PM +0000, Alexander Konyukhov wrote: > > 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 > > --- > > drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c > > index 3ca461eb0a24..3cb34d03f7f8 100644 > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c > > @@ -4,6 +4,8 @@ > > * Author: James.Qian.Wang > > * > > */ > > +#include > > + > > #include > > #include > > #include > > @@ -93,7 +95,9 @@ komeda_fb_afbc_size_check(struct komeda_fb *kfb, struct drm_file *file, > > kfb->afbc_size = kfb->offset_payload + n_blocks * > > ALIGN(bpp * AFBC_SUPERBLK_PIXELS / 8, > > AFBC_SUPERBLK_ALIGNMENT); > > - min_size = kfb->afbc_size + fb->offsets[0]; > > Can this really overflow? Is the concern a hypothetical ILP64 > situation? > > min_size is u64, kfb->afbc_size is u32, and fb->offsets[0] is unsigned > int. Yeah, I was thinking the same thing yesterday at the end of the work day when I looked at the patch. I don't think following the call flow you can end up with an overflow. Best regards, Liviu > > Thanks, > -Brian > > > + if (check_add_overflow(kfb->afbc_size, fb->offsets[0], &min_size)) { > > + goto check_failed; > > + } > > if (min_size > obj->size) { > > DRM_DEBUG_KMS("afbc size check failed, obj_size: 0x%zx. min_size 0x%llx.\n", > > obj->size, min_size); > > -- > > 2.43.0 > >