From: sashiko-bot@kernel.org
To: "Thomas Zimmermann" <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/sysfb: Return errno code from drm_sysfb_get_visible_size()
Date: Wed, 17 Jun 2026 11:40:15 +0000 [thread overview]
Message-ID: <20260617114016.5A5991F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260617112932.511657-3-tzimmermann@suse.de>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] 32-bit integer overflow in `height * stride` calculation leading to out-of-bounds I/O memory mapping and subsequent out-of-bounds writes.
- [Medium] Truncation of `div64_u64` result when passed to the `u32 max` parameter of `drm_sysfb_get_validated_int0`.
--
commit caeaafe04348540484a7b3b0bfa6ff4db7c32a32
Author: Thomas Zimmermann <tzimmermann@suse.de>
drm/sysfb: Return errno code from drm_sysfb_get_visible_size()
Change the return type of drm_sysfb_get_visible_size() to s64 so
that it returns a possible errno code from _get_validated_size0().
Fix callers to handle the errno code.
> diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c b/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c
> index 361b7233600c2..40b4f7883b9bc 100644
> --- a/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c
> +++ b/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c
> @@ -64,7 +64,7 @@ int drm_sysfb_get_stride_si(struct drm_device *dev, const struct screen_info *si
> }
> EXPORT_SYMBOL(drm_sysfb_get_stride_si);
>
> -u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
> +s64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
> unsigned int height, unsigned int stride, u64 size)
> {
> u64 vsize = height * stride;
[Severity: High]
This is a pre-existing issue, but does this calculation overflow if height
and stride are large?
Both height and stride are passed as 32-bit unsigned integers to
drm_sysfb_get_visible_size_si(), so their product is computed as a 32-bit
unsigned integer before being implicitly extended to the 64-bit vsize.
If they overflow (e.g., height up to U16_MAX and stride up to U16_MAX * 4),
the truncated 32-bit value could bypass the bounds check in
drm_sysfb_get_validated_size0(). This could result in requesting and mapping
a falsely small I/O memory region for the framebuffer, potentially leading
to an out-of-bounds memory write later.
Could explicit 64-bit casting or mul_u32_u32() be used to prevent this?
[Severity: Medium]
This isn't a bug introduced by this patch, but looking at
drm_sysfb_get_stride_si() located just above this in
drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c:
int drm_sysfb_get_stride_si(...)
{
...
return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength,
div64_u64(size, height));
}
Could the result of div64_u64(size, height) be truncated when passed to
drm_sysfb_get_validated_int0()?
The max parameter of drm_sysfb_get_validated_int0() is typed as u32. If
the total resource size is large and the height is small (for example,
size = 4GB and height = 1), the division result would overflow the u32 type
and truncate to 0.
This would cause drm_sysfb_get_validated_int0() to use a max value of 0,
falsely rejecting a valid configuration with -EINVAL.
> return drm_sysfb_get_validated_size0(dev, "visible size", vsize, size);
> }
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260617112932.511657-1-tzimmermann@suse.de?part=2
next prev parent reply other threads:[~2026-06-17 11:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 11:27 [PATCH 0/2] drm/sysfb: Fix visible size and related checks Thomas Zimmermann
2026-06-17 11:27 ` [PATCH 1/2] drm/sysfb: Do not page-align visible size of the framebuffer Thomas Zimmermann
2026-06-17 11:40 ` sashiko-bot
2026-06-17 11:44 ` Javier Martinez Canillas
2026-06-17 12:36 ` Thomas Zimmermann
2026-06-17 11:27 ` [PATCH 2/2] drm/sysfb: Return errno code from drm_sysfb_get_visible_size() Thomas Zimmermann
2026-06-17 11:40 ` sashiko-bot [this message]
2026-06-17 11:45 ` Javier Martinez Canillas
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=20260617114016.5A5991F000E9@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.