Skip to contentSkip to conversation

First cleanup patch

KJ Steven Jones 2 participants 2 messages Aug 10, 2006 Kernel janitors

lore
Share & tools
lore
#0 lore raw

G'day,
This is my first attempt at patching something in the kernel so
be gentle. Actually, don't be gentle, but please be very descriptive in exactly what it is I'm doing wrong. (I know there will be something).

This is a patch to check the return value of copy_to_user. I have got as far as linking an allyes kernel with the patch applied but have not booted it (I don't have the card in question). The only thing I was not certain about in the patch is the possibility that the function could infinite loop if copy_to_user continually failed completely. I don't know if this is a real posibility, would anyone like to comment.

The patch is against 2.6.18-rc3.

PS. I am having difficulties fighting with evolution over line wraps, can someone let me know if this ends up being html or clean text.

drivers/isdn/hisax/config.c +5 -2
diff -ruNp orig/drivers/isdn/hisax/config.c work/drivers/isdn/hisax/config.c
@@ -619,6 +619,7 @@ struct IsdnCardState *hisax_get_card(int
 static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
 {
 	int count, cnt;
+	int missed;
 	u_char __user *p = buf;
 	struct IsdnCardState *cs = hisax_findcard(id);
 
@@ -631,7 +632,8 @@ static int HiSax_readstatus(u_char __use
 		count = cs->status_end - cs->status_read + 1;
 		if (count >= len)
 			count = len;
-		copy_to_user(p, cs->status_read, count);
+		missed = copy_to_user(p, cs->status_read, count);
+		count -= missed;
 		cs->status_read += count;
 		if (cs->status_read > cs->status_end)
 			cs->status_read = cs->status_buf;
@@ -642,7 +644,8 @@ static int HiSax_readstatus(u_char __use
 				cnt = HISAX_STATUS_BUFSIZE;
 			else
 				cnt = count;
-			copy_to_user(p, cs->status_read, cnt);
+			missed = copy_to_user(p, cs->status_read, cnt);
+			cnt -= missed;
 			p += cnt;
 			cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
 			count -= cnt;

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw
Quoted 1 line

G'day,

Hi Steven,

Quoted 2 lines

PS. I am having difficulties fighting with evolution over line wraps, can
someone let me know if this ends up being html or clean text.

Your mail shows as a multi-part MIME message, with a clean version and a html one...
The patch does not seem affected with line wrap, but you may want to re-post your mail in a pure text format...

I did not have a look on copy_to_user() yet, but what happens if it answers with a 0 value ? (with regards to your comment about a possible infinite loop).

Regards,
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors