mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: oushixiong1025@163.com
Cc: Javier Martinez Canillas <javierm@redhat.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.or, linux-kernel@vger.kernel.org,
	Shixiong Ou <oushixiong@kylinos.cn>
Subject: Re: [PATCH] drm/sysfb: ofdrm: Fix integer overflow in fb_size calculation
Date: Fri, 24 Jul 2026 13:37:15 +0200	[thread overview]
Message-ID: <ecb09443-37b2-4a04-bea9-ed59f05aa5b1@suse.de> (raw)
In-Reply-To: <20260724094108.793720-1-oushixiong1025@163.com>



Am 24.07.26 um 11:41 schrieb oushixiong1025@163.com:
> From: Shixiong Ou <oushixiong@kylinos.cn>
>
> The framebuffer size calculation `fb_size = linebytes * height` can
> overflow when both values are large (e.g., 46341 * 46341 > INT_MAX).
> Since linebytes and height are both int types, the multiplication is
> performed as int * int, which results in undefined behavior on overflow.
>
> Use check_mul_overflow() to detect and prevent this overflow, consistent
> with the approach used in simpledrm.c and corebootdrm.c.
>
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Thanks for the fix.

> ---
>   drivers/gpu/drm/sysfb/ofdrm.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c
> index 819aed466727..a6dc34b9ec0f 100644
> --- a/drivers/gpu/drm/sysfb/ofdrm.c
> +++ b/drivers/gpu/drm/sysfb/ofdrm.c
> @@ -2,6 +2,7 @@
>   
>   #include <linux/aperture.h>
>   #include <linux/of_address.h>
> +#include <linux/overflow.h>
>   #include <linux/pci.h>
>   #include <linux/platform_device.h>
>   #include <linux/pm.h>
> @@ -913,7 +914,10 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv,
>   			return ERR_PTR(-EINVAL);
>   	}
>   
> -	fb_size = linebytes * height;
> +	if (check_mul_overflow(linebytes, height, &fb_size)) {
> +		drm_err(dev, "framebuffer size exceeds maximum\n");
> +		return ERR_PTR(-EINVAL);
> +	}
>   
>   	/*
>   	 * Try to figure out the address of the framebuffer. Unfortunately, Open

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)



      reply	other threads:[~2026-07-24 11:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  9:41 oushixiong1025
2026-07-24 11:37 ` Thomas Zimmermann [this message]

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=ecb09443-37b2-4a04-bea9-ed59f05aa5b1@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.or \
    --cc=javierm@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=oushixiong1025@163.com \
    --cc=oushixiong@kylinos.cn \
    --cc=simona@ffwll.ch \
    /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

all inboxes | Powered by JetHome®