From: sashiko-bot@kernel.org
To: "Thomas Zimmermann" <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 1/3] drm/armada: fbdev: Calculate buffer geometry with format helpers
Date: Thu, 11 Jun 2026 07:30:49 +0000 [thread overview]
Message-ID: <20260611073049.DA3661F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611072121.71492-2-tzimmermann@suse.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The newly added `check_mul_overflow` check is completely ineffective because it stores the result in a `u64` variable. Since both operands (`pitch` and `sizes->surface_height`) are `u32`, their product can never overflow a 64-bit integer, meaning the check always passes. The `u64` size is then implicitly truncated to 32 bits when passed to `armada_gem_alloc_private_object()`, which expects a `size_t` argument. This completely bypasses the intended overflow protection.
--
commit 9304c78ca806a472129099acb5c200bab2e752a0
Author: Thomas Zimmermann <tzimmermann@suse.de>
drm/armada: fbdev: Calculate buffer geometry with format helpers
This commit replaces the geometry and size calculation in armada's fbdev
emulation with DRM format helpers. It uses a 4CC lookup, pitch calculation,
and allocates the GEM buffer object for the framebuffer memory aligned to
PAGE_SIZE.
> diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
> index 8bbae94804f8b..f95658091acf2 100644
> --- a/drivers/gpu/drm/armada/armada_fbdev.c
> +++ b/drivers/gpu/drm/armada/armada_fbdev.c
> @@ -45,20 +45,30 @@ int armada_fbdev_driver_fbdev_probe(struct drm_fb_helper *fbh,
> {
[ ... ]
> + if (check_mul_overflow(pitch, sizes->surface_height, &size))
> + return -EINVAL;
> + size = ALIGN(size, PAGE_SIZE);
> + if (size < PAGE_SIZE)
> + return -EINVAL;
>
> - size = mode.pitches[0] * mode.height;
> obj = armada_gem_alloc_private_object(dev, size);
[Severity: High]
This isn't a bug introduced by this patch, but does this check_mul_overflow()
actually prevent overflow here?
Since pitch and sizes->surface_height are 32-bit unsigned integers, and size
is a u64, the multiplication will never overflow the 64-bit target, so the
check will always pass.
However, when size is passed to armada_gem_alloc_private_object(), which
takes a size_t argument, couldn't this silently truncate to 32 bits since
the Armada DRM driver operates on a 32-bit architecture?
For example, if pitch * height evaluates to 0xFFFFFFFF, ALIGN() expands it
to 0x100000000. The check size < PAGE_SIZE evaluates to false on the u64,
but when passed to armada_gem_alloc_private_object(), the size truncates
to 0, resulting in an undersized buffer allocation.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260611072121.71492-1-tzimmermann@suse.de?part=1
next prev parent reply other threads:[~2026-06-11 7:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 7:20 [PATCH v2 0/3] drm/armada: fbdev: Use client buffers Thomas Zimmermann
2026-06-11 7:20 ` [PATCH v2 1/3] drm/armada: fbdev: Calculate buffer geometry with format helpers Thomas Zimmermann
2026-06-11 7:30 ` sashiko-bot [this message]
2026-06-11 7:20 ` [PATCH v2 2/3] drm/armada: fbdev: Use a DRM client buffer Thomas Zimmermann
2026-06-11 7:20 ` [PATCH v2 3/3] drm/armada: Make armada_framebuffer_create() an internal interface Thomas Zimmermann
2026-06-11 7:28 ` sashiko-bot
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=20260611073049.DA3661F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.