From: Liviu Dudau <liviu.dudau@arm.com>
To: Brian Starkey <brian.starkey@arm.com>
Cc: Alexander Konyukhov <Alexander.Konyukhov@kaspersky.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
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
Date: Wed, 4 Feb 2026 13:24:30 +0000 [thread overview]
Message-ID: <aYNIjm8XIdxKNo-0@e142607> (raw)
In-Reply-To: <ct5tkr764socel5o4gtd4k2fgofqiljy3yzdjokij3jjkcf2ks@c3p7fs33znoe>
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 <Alexander.Konyukhov@kaspersky.com>
> > ---
> > 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 <james.qian.wang@arm.com>
> > *
> > */
> > +#include <linux/overflow.h>
> > +
> > #include <drm/drm_device.h>
> > #include <drm/drm_fb_dma_helper.h>
> > #include <drm/drm_gem.h>
> > @@ -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
> >
next prev parent reply other threads:[~2026-02-04 13:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 13:48 [PATCH] drm/komeda: fix integer overflow in AFBC framebuffer size check Alexander Konyukhov
2026-02-03 21:43 ` Brian Starkey
2026-02-04 13:24 ` Liviu Dudau [this message]
2026-02-04 14:56 ` Alexander Konyukhov
2026-02-04 15:05 ` Liviu Dudau
2026-02-04 16:20 ` Brian Starkey
2026-02-05 13:35 ` Liviu Dudau
2026-03-19 14:44 ` Fedor Pchelkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aYNIjm8XIdxKNo-0@e142607 \
--to=liviu.dudau@arm.com \
--cc=Alexander.Konyukhov@kaspersky.com \
--cc=airlied@gmail.com \
--cc=brian.starkey@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nd@arm.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox