Skip to contentSkip to conversation

CAN-2004-0003 R128 DRI limits checking.

SECURITY Dave Jones 1 participant 1 message Mar 9, 2004 Char and misc drivers

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

This got fixed in 2.4, but somehow got missed in 2.6.
http://icat.nist.gov/icat.cfm?cvename=CAN-2004-0003 has more info.

Dave

drivers/char/drm/r128_state.c renamed from drivers/char/drm/r128_state.c~ +11 -0
@@ -915,6 +915,9 @@
 	DRM_DEBUG( "\n" );
 
 	count = depth->n;
+	if (count > 4096 || count <= 0)
+		return -EMSGSIZE;
+
 	if ( DRM_COPY_FROM_USER( &x, depth->x, sizeof(x) ) ) {
 		return DRM_ERR(EFAULT);
 	}
@@ -1008,6 +1011,8 @@
 	DRM_DEBUG( "\n" );
 
 	count = depth->n;
+	if (count > 4096  || count <= 0)
+		return -EMSGSIZE;
 
 	xbuf_size = count * sizeof(*x);
 	ybuf_size = count * sizeof(*y);
@@ -1125,6 +1130,9 @@
 	DRM_DEBUG( "\n" );
 
 	count = depth->n;
+	if (count > 4096 || count <= 0)
+		return -EMSGSIZE;
+
 	if ( DRM_COPY_FROM_USER( &x, depth->x, sizeof(x) ) ) {
 		return DRM_ERR(EFAULT);
 	}
@@ -1167,6 +1175,9 @@
 	DRM_DEBUG( "%s\n", __FUNCTION__ );
 
 	count = depth->n;
+	if (count > 4096 || count <= 0)
+		return -EMSGSIZE;
+
 	if ( count > dev_priv->depth_pitch ) {
 		count = dev_priv->depth_pitch;
 	}