public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe W Damasio <felipewd@terra.com.br>
To: gadio@netvision.net.il
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] copy_{to|from}_user checks in ide-tape
Date: Mon, 06 Oct 2003 11:27:56 -0300	[thread overview]
Message-ID: <3F817BEC.8090006@terra.com.br> (raw)

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

	Hi Gadi,

(unchecked values found by smatch).

	Patch against 2.6-test6.

	idetape_copy_stage_{from|to}_user assume that copy_{from|to}_user 
will always return 0, which seems wrong.

	*But* I'm not sure if the copy fails we should "return" or "continue" 
to try again. This patch follows the former approach.

	In either case, if we fail and give up at some point, there's no way 
to return the error code, since these functions return void. I don't 
know squad about this driver, but I think this kind of "assumes 
everything will turn out OK" API is wrong.

	Please consider applying and let me know if you want to re-implement 
the copy_stage functions to return a OK/Non-OK value.

	Cheers,

Felipe

[-- Attachment #2: ide-tape_copy.patch --]
[-- Type: text/plain, Size: 806 bytes --]

--- linux-2.6.0-test6/drivers/ide/ide-tape.c.orig	2003-10-06 11:13:00.000000000 -0300
+++ linux-2.6.0-test6/drivers/ide/ide-tape.c	2003-10-06 11:17:42.000000000 -0300
@@ -3026,7 +3026,8 @@
 		}
 #endif /* IDETAPE_DEBUG_BUGS */
 		count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), (unsigned int)n);
-		copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count);
+		if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count))
+			return;
 		n -= count;
 		atomic_add(count, &bh->b_count);
 		buf += count;
@@ -3053,7 +3054,8 @@
 		}
 #endif /* IDETAPE_DEBUG_BUGS */
 		count = min(tape->b_count, n);
-		copy_to_user(buf, tape->b_data, count);
+		if (copy_to_user(buf, tape->b_data, count))
+			return;
 		n -= count;
 		tape->b_data += count;
 		tape->b_count -= count;

                 reply	other threads:[~2003-10-06 14:24 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=3F817BEC.8090006@terra.com.br \
    --to=felipewd@terra.com.br \
    --cc=gadio@netvision.net.il \
    --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