mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
cdrom: use copy_to_user() without the underscores
commit 822bfa51ce
upstream.
"nframes" comes from the user and "nframes * CD_FRAMESIZE_RAW" can wrap
on 32 bit systems. That would have been ok if we used the same wrapped
value for the copy, but we use a shifted value. We should just use the
checked version of copy_to_user() because it's not going to make a
difference to the speed.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
This commit is contained in:
parent
aa6333a71f
commit
c0a0cff0f5
@ -2044,11 +2044,6 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
|
||||
if (!nr)
|
||||
return -ENOMEM;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE, ubuf, nframes * CD_FRAMESIZE_RAW)) {
|
||||
ret = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
cgc.data_direction = CGC_DATA_READ;
|
||||
while (nframes > 0) {
|
||||
if (nr > nframes)
|
||||
@ -2057,7 +2052,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
|
||||
ret = cdrom_read_block(cdi, &cgc, lba, nr, 1, CD_FRAMESIZE_RAW);
|
||||
if (ret)
|
||||
break;
|
||||
if (__copy_to_user(ubuf, cgc.buffer, CD_FRAMESIZE_RAW * nr)) {
|
||||
if (copy_to_user(ubuf, cgc.buffer, CD_FRAMESIZE_RAW * nr)) {
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
}
|
||||
@ -2065,7 +2060,6 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
|
||||
nframes -= nr;
|
||||
lba += nr;
|
||||
}
|
||||
out:
|
||||
kfree(cgc.buffer);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user