mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesper Juhl <juhl-lkml@dif.dk>
To: isdn4linux <isdn4linux@listserv.isdn4linux.de>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Karsten Keil <keil@isdn4linux.de>,
	Kai Germaschewski <kai.germaschewski@gmx.de>
Subject: [patch] copy_to_user return value checks in drivers/isdn/hisax/config.c
Date: Thu, 6 Jan 2005 23:58:23 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.61.0501062353420.3430@dragon.hygekrogen.localhost> (raw)


Hi,

Here's a proposed patch for drivers/isdn/hisax/config.c to make sure the 
return value from copy_to_user gets checked and acted upon properly.
I don't have hardware to test this, so please review carefully before 
applying - I think it does the right thing, but I can't really test to 
know for sure.

Pplease keep me on CC as I'm not subscribed to the isdn4linux list.


Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

diff -up linux-2.6.10-bk9-orig/drivers/isdn/hisax/config.c linux-2.6.10-bk9/drivers/isdn/hisax/config.c
--- linux-2.6.10-bk9-orig/drivers/isdn/hisax/config.c	2004-12-24 22:35:25.000000000 +0100
+++ linux-2.6.10-bk9/drivers/isdn/hisax/config.c	2005-01-06 23:49:19.000000000 +0100
@@ -625,6 +625,7 @@ int HiSax_readstatus(u_char __user *buf,
 	struct IsdnCardState *cs = hisax_findcard(id);
 
 	if (cs) {
+		int residue;
 		if (len > HISAX_STATUS_BUFSIZE) {
 			printk(KERN_WARNING
 			       "HiSax: status overflow readstat %d/%d\n",
@@ -633,7 +634,8 @@ int HiSax_readstatus(u_char __user *buf,
 		count = cs->status_end - cs->status_read + 1;
 		if (count >= len)
 			count = len;
-		copy_to_user(p, cs->status_read, count);
+		if (copy_to_user(p, cs->status_read, count))
+			return -EFAULT;
 		cs->status_read += count;
 		if (cs->status_read > cs->status_end)
 			cs->status_read = cs->status_buf;
@@ -644,9 +646,12 @@ int HiSax_readstatus(u_char __user *buf,
 				cnt = HISAX_STATUS_BUFSIZE;
 			else
 				cnt = count;
-			copy_to_user(p, cs->status_read, cnt);
+			if ((residue = copy_to_user(p, cs->status_read, cnt)) != 0)
+				cnt -= residue;
 			p += cnt;
 			cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
+			if (residue)
+				return -EFAULT;
 			count -= cnt;
 		}
 		return len;




                 reply	other threads:[~2005-01-06 22:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0501062353420.3430@dragon.hygekrogen.localhost \
    --to=juhl-lkml@dif.dk \
    --cc=isdn4linux@listserv.isdn4linux.de \
    --cc=kai.germaschewski@gmx.de \
    --cc=keil@isdn4linux.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®