Skip to contentSkip to conversation

emu10k1 forward port (2.4.20 to 2.5.56)

PATCH Alistair Strachan 2 participants 2 messages Jan 15, 2003

lore
Share & tools
lore
#0 lore raw

Hi,

This diff applies over the top of Rui's diff to provide the __copy_{to,from}_user fixes present in -dj. The merging of both these diffs would remove all the remaining important emu10k1 changes from -dj.

Cheers,
Alistair Strachan.

audio.c +1 -1
diff -Nudr -U3 emu10k1-rui/audio.c emu10k1-mine/audio.c
@@ -793,7 +799,7 @@
 				cinfo.blocks = 0;
 			}
 
-			if(wiinst->mmapped)
+			if (wiinst->mmapped)
 				wiinst->buffer.bytestocopy %= wiinst->buffer.fragment_size;
 
 			spin_unlock_irqrestore(&wiinst->lock, flags);
cardwi.c +6 -4
diff -Nudr -U3 emu10k1-rui/cardwi.c emu10k1-mine/cardwi.c
@@ -307,9 +307,10 @@
 
 static void copy_block(u8 *dst, u8 * src, u32 str, u32 len, u8 cov)
 {
-	if (cov == 1)
-		__copy_to_user(dst, src + str, len);
-	else {
+	if (cov == 1) {
+		if (__copy_to_user(dst, src + str, len))
+			return;
+	} else {
 		u8 byte;
 		u32 i;
 
@@ -317,7 +318,8 @@
 
 		for (i = 0; i < len; i++) {
 			byte = src[2 * i] ^ 0x80;
-			__copy_to_user(dst + i, &byte, 1);
+			if (__copy_to_user(dst + i, &byte, 1))
+				return;
 		}
 	}
 }
cardwo.c +8 -5
diff -Nudr -U3 emu10k1-rui/cardwo.c emu10k1-mine/cardwo.c
@@ -408,15 +408,17 @@
 
 	if (len > PAGE_SIZE - pgoff) {
 		k = PAGE_SIZE - pgoff;
-		__copy_from_user((u8 *)dst[pg] + pgoff, src, k);
+		if (__copy_from_user((u8 *)dst[pg] + pgoff, src, k))
+			return;
 		len -= k;
 		while (len > PAGE_SIZE) {
-			__copy_from_user(dst[++pg], src + k, PAGE_SIZE);
+			if (__copy_from_user(dst[++pg], src + k, PAGE_SIZE))
+				return;
 			k += PAGE_SIZE;
 			len -= PAGE_SIZE;
 		}
-		__copy_from_user(dst[++pg], src + k, len);
-
+		if (__copy_from_user(dst[++pg], src + k, len))
+			return;
 	} else
 		__copy_from_user((u8 *)dst[pg] + pgoff, src, len);
 }
@@ -440,7 +442,8 @@
 
 	while (len) { 
 		for (voice_num = 0; voice_num < woinst->num_voices; voice_num++) {
-			__copy_from_user((u8 *)(voice[voice_num].mem.addr[pg]) + pgoff, src, woinst->format.bytespervoicesample);
+			if (__copy_from_user((u8 *)(voice[voice_num].mem.addr[pg]) + pgoff, src, woinst->format.bytespervoicesample))
+				return;
 			src += woinst->format.bytespervoicesample;
 		}
 
midi.c +1 -2
diff -Nudr -U3 emu10k1-rui/midi.c emu10k1-mine/midi.c
@@ -122,9 +122,8 @@
 		up(&card->open_sem);
 		interruptible_sleep_on(&card->open_wait);
 
-		if (signal_pending(current)) {
+		if (signal_pending(current))
 			return -ERESTARTSYS;
-		}
 
 		down(&card->open_sem);
 	}
passthrough.c +9 -4
diff -Nudr -U3 emu10k1-rui/passthrough.c emu10k1-mine/passthrough.c
@@ -165,12 +165,15 @@
 
 		DPD(3, "prepend size %d, prepending %d bytes\n", pt->prepend_size, needed);
 		if (count < needed) {
-			copy_from_user(pt->buf + pt->prepend_size, buffer, count);
+			if (copy_from_user(pt->buf + pt->prepend_size, buffer,
+					   count))
+				return -EFAULT;
 			pt->prepend_size += count;
 			DPD(3, "prepend size now %d\n", pt->prepend_size);
 			return count;
 		}
-		copy_from_user(pt->buf + pt->prepend_size, buffer, needed);
+		if (copy_from_user(pt->buf + pt->prepend_size, buffer, needed))
+			return -EFAULT;
 		r = pt_putblock(wave_dev, (u16 *) pt->buf, nonblock);
 		if (r)
 			return r;
@@ -181,7 +184,8 @@
 	blocks_copied = 0;
 	while (blocks > 0) {
 		u16 *bufptr = (u16 *) buffer + (bytes_copied/2);
-		copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE);
+		if (copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE))
+			return -EFAULT;
 		bufptr = (u16 *) pt->buf;
 		r = pt_putblock(wave_dev, bufptr, nonblock);
 		if (r) {
@@ -197,7 +201,8 @@
 	i = count - bytes_copied;
 	if (i) {
 		pt->prepend_size = i;
-		copy_from_user(pt->buf, buffer + bytes_copied, i);
+		if (copy_from_user(pt->buf, buffer + bytes_copied, i))
+			return -EFAULT;
 		bytes_copied += i;
 		DPD(3, "filling prepend buffer with %d bytes", i);
 	}
#1 lore raw

On Wed, 15 Jan 2003, Alistair Strachan wrote:

I'm still not sure if I agree with this change... Couldn't be possible that even if one __copy_from_user() fails the next one could succeed? Is it really necessary to return at the first error?

Rui

Quoted 9 lines

Hi,

This diff applies over the top of Rui's diff to provide the __copy_{to,from}_user fixes present in -dj. The merging of both these diffs would remove all the remaining important emu10k1 changes from -dj.

Cheers,
Alistair Strachan.