Skip to contentSkip to conversation

FAILED: patch "[PATCH] drm/i915/gem: Detect overflow in calculating dumb buffer size" failed to apply to 5.5-stable tree

PATCH [email protected] 1 participant 1 message Feb 17, 2020

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.5-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]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 051c89cf4ac487e795d87e6f3b9e0ff788da8fb4 Mon Sep 17 00:00:00 2001
From: Chris Wilson <[email protected]>
Date: Thu, 23 Jan 2020 12:59:34 +0000
Subject: [PATCH] drm/i915/gem: Detect overflow in calculating dumb buffer size
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

To multiply 2 u32 numbers to generate a u64 in C requires a bit of forewarning for the compiler.

Cc Ramalingam C <[email protected]>
Cc Joonas Lahtinen <[email protected]>
(cherry picked from commit 0f8f8a64300092852b9361cd835395ee71e6a7d6)
drivers/gpu/drm/i915/i915_gem.c +4 -1
index 94f993e4c12f..c2de2f45b459 100644
@@ -265,7 +265,10 @@ i915_gem_dumb_create(struct drm_file *file,
 						    DRM_FORMAT_MOD_LINEAR))
 		args->pitch = ALIGN(args->pitch, 4096);
 
-	args->size = args->pitch * args->height;
+	if (args->pitch < args->width)
+		return -EINVAL;
+
+	args->size = mul_u32_u32(args->pitch, args->height);
 
 	mem_type = INTEL_MEMORY_SYSTEM;
 	if (HAS_LMEM(to_i915(dev)))