From: Jesper Juhl <juhl-lkml@dif.dk>
To: Jens Axboe <axboe@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] remember to check return value from __copy_to_user() in cdrom_read_cdda_old()
Date: Mon, 6 Sep 2004 23:46:47 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.61.0409062335250.2705@dragon.hygekrogen.localhost> (raw)
Hi,
Here's a patch to ensure that the return value from __copy_to_user() gets
checked in cdrom_read_cdda_old().
I assume that returning -EFAULT if the copy fails to copy all bytes is an
appropriate action, but please correct me if I'm wrong.
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
diff -up linux-2.6.9-rc1-bk13-orig/drivers/cdrom/cdrom.c linux-2.6.9-rc1-bk13/drivers/cdrom/cdrom.c
--- linux-2.6.9-rc1-bk13-orig/drivers/cdrom/cdrom.c 2004-08-24 20:44:01.000000000 +0200
+++ linux-2.6.9-rc1-bk13/drivers/cdrom/cdrom.c 2004-09-06 23:41:20.000000000 +0200
@@ -1959,7 +1959,10 @@ static int cdrom_read_cdda_old(struct cd
ret = cdrom_read_block(cdi, &cgc, lba, nr, 1, CD_FRAMESIZE_RAW);
if (ret)
break;
- __copy_to_user(ubuf, cgc.buffer, CD_FRAMESIZE_RAW * nr);
+ if (__copy_to_user(ubuf, cgc.buffer, CD_FRAMESIZE_RAW * nr)) {
+ kfree(cgc.buffer);
+ return -EFAULT;
+ }
ubuf += CD_FRAMESIZE_RAW * nr;
nframes -= nr;
lba += nr;
I'm wondering if it would make sense to wrap this branch in unlikely()
since it should rarely fail...?
I should also mention that I've only compile tested this so far.
--
Jesper Juhl
next reply other threads:[~2004-09-06 21:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-06 21:46 Jesper Juhl [this message]
2004-09-07 8:02 ` Jens Axboe
2004-09-07 9:32 ` Paul Mackerras
2004-09-07 9:34 ` Jens Axboe
2004-09-07 9:59 ` Andrew Morton
2004-09-07 10:09 ` Jens Axboe
2004-09-07 10:12 ` Andrew Morton
2004-09-07 10:15 ` Jens Axboe
2004-09-07 10:23 ` viro
2004-09-07 10:30 ` Jens Axboe
2004-09-07 10:45 ` viro
2004-09-07 11:42 ` Jens Axboe
2004-09-07 9:58 ` Jens Axboe
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.0409062335250.2705@dragon.hygekrogen.localhost \
--to=juhl-lkml@dif.dk \
--cc=axboe@suse.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®