FAILED: patch "[PATCH] drm/sysfb: ofdrm: Fix integer overflow in fb_size calculation" failed to apply to 6.6-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x c6f48e59ece0123f6a11527ad4d89b21c2d65b87
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090951-customary-distract-703c@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c6f48e59ece0123f6a11527ad4d89b21c2d65b87 Mon Sep 17 00:00:00 2001
From: Shixiong Ou <[email protected]>
Date: Tue, 25 Aug 2026 18:41:34 +0800
Subject: [PATCH] drm/sysfb: ofdrm: Fix integer overflow in fb_size calculation
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.
drivers/gpu/drm/sysfb/ofdrm.c +5 -1
@@ -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
Sasha Levin
maintainerPATCH 1/1 drm/sysfb: ofdrm: Fix integer overflow in fb_size calculation
From: Shixiong Ou <[email protected]>
[ Upstream commit c6f48e59ece0123f6a11527ad4d89b21c2d65b87 ]
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.
--- drivers/gpu/drm/tiny/ofdrm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/tiny/ofdrm.c +5 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only #include <linux/of_address.h> +#include <linux/overflow.h> #include <linux/pci.h> #include <linux/platform_device.h>
@@ -1169,7 +1170,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
Signature · 1 line
2.53.0