Skip to contentSkip to conversation

2.4.23: user/kernel pointer bugs (vicam.c, w9968cf.c)

PATCH Robert T. Johnson 2 participants 2 messages Jan 7, 2004 – Jan 8, 2004

lore
Share & tools
lore
#0 lore raw

I think there are exploitable user/kernel pointer bugs in vicam.c and w9968cf.c. The bugs are very simple, so I think the patches speak for themselves. Thanks for looking at this, and my apologies if I've made any mistakes. Let me know if you have any questions.

Best,
Rob

P.S. Both of these bugs were found using the source code verification tool, CQual, developed by Jeff Foster, myself, and others, and available from http://www.cs.umd.edu/~jfoster/cqual/.

usb/vicam.c renamed from usb/vicam.c.orig +10 -3
@@ -601,12 +601,19 @@
 	case VIDIOCSWIN:
 		{
 
-			struct video_window *vw = (struct video_window *) arg;
-			DBG("VIDIOCSWIN %d x %d\n", vw->width, vw->height);
+			struct video_window vw;
 
-			if ( vw->width != 320 || vw->height != 240 )
+			if (copy_from_user(&vw, arg, sizeof(vw)))
+			{
 				retval = -EFAULT;
+				break;
+			}
+
+			DBG("VIDIOCSWIN %d x %d\n", vw->width, vw->height);
 			
+			if ( vw.width != 320 || vw.height != 240 )
+				retval = -EFAULT;
+
 			break;
 		}
 
usb/w9968cf.c renamed from usb/w9968cf.c.orig +6 -2
@@ -3552,10 +3552,13 @@
 
 	case VIDIOCSYNC: /* wait until the capture of a frame is finished */
 	{
-		unsigned int f_num = *((unsigned int *) arg);
+		unsigned int f_num;
 		struct w9968cf_frame_t* fr;
 		int err = 0;
 
+		if (copy_from_user(&f_num, arg, sizeof(f_num)))
+			return -EFAULT;
+
 		if (f_num >= cam->nbuffers) {
 			DBG(4, "Invalid frame number (%d). "
 			       "VIDIOCMCAPTURE failed.", f_num)
@@ -3620,7 +3623,8 @@
 	{
 		struct video_buffer* buffer = (struct video_buffer*)arg;
 
-		memset(buffer, 0, sizeof(struct video_buffer));
+		if (clear_user(buffer, sizeof(struct video_buffer)))
+			return -EFAULT;
 
 		DBG(5, "VIDIOCGFBUF successfully called.")
 		return 0;
#1 lore raw

Thanks for your help.

Quoted 40 lines · Robert T. Johnson

I think there are exploitable user/kernel pointer bugs in vicam.c and w9968cf.c. The bugs are very simple, so I think the patches speak for themselves. Thanks for looking at this, and my apologies if I've made any mistakes. Let me know if you have any questions.

Best,
Rob

P.S. Both of these bugs were found using the source code verification tool, CQual, developed by Jeff Foster, myself, and others, and available from http://www.cs.umd.edu/~jfoster/cqual/.

usb/w9968cf.c renamed from usb/w9968cf.c.orig +6 -2
@@ -3552,10 +3552,13 @@
 
 	case VIDIOCSYNC: /* wait until the capture of a frame is finished */
 	{
-		unsigned int f_num = *((unsigned int *) arg);
+		unsigned int f_num;
 		struct w9968cf_frame_t* fr;
 		int err = 0;
 
+		if (copy_from_user(&f_num, arg, sizeof(f_num)))
+			return -EFAULT;
+
 		if (f_num >= cam->nbuffers) {
 			DBG(4, "Invalid frame number (%d). "
 			       "VIDIOCMCAPTURE failed.", f_num)
@@ -3620,7 +3623,8 @@
 	{
 		struct video_buffer* buffer = (struct video_buffer*)arg;
 
-		memset(buffer, 0, sizeof(struct video_buffer));
+		if (clear_user(buffer, sizeof(struct video_buffer)))
+			return -EFAULT;
 
 		DBG(5, "VIDIOCGFBUF successfully called.")
 		return 0;