Skip to contentSkip to conversation

drm: crtc: integer overflow in drm_property_create_blob()

PATCH In review Dan Carpenter 2 participants 2 messages Oct 29, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: crtc: integer overflow in drm_property_create_blob()

The size here comes from the user via the ioctl, it is a number between 1-u32max so the addition here could overflow on 32 bit systems.

Fixes f453ba046074 ('DRM: add mode setting support')
drivers/gpu/drm/drm_crtc.c +1 -1
index e54660a..627b2d0 100644
@@ -4107,7 +4107,7 @@ drm_property_create_blob(struct drm_device *dev, size_t length,
 	struct drm_property_blob *blob;
 	int ret;
 
-	if (!length)
+	if (!length || length > ULONG_MAX - sizeof(struct drm_property_blob))
 		return ERR_PTR(-EINVAL);
 
 	blob = kzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL);
Reviewed-by on v1 1/1
#1 lore raw

Hi Dan,

Quoted 5 lines · Dan Carpenter

The size here comes from the user via the ioctl, it is a number between 1-u32max so the addition here could overflow on 32 bit systems.

Fixes f453ba046074 ('DRM: add mode setting support')

Thanks for catching this. I did have a pass through looking for such issues but couldn't see any. :\

Cheers,
Daniel