]> git.karo-electronics.de Git - karo-tx-linux.git/commit
drivers/cdrom/cdrom.c: use kzalloc() for failing hardware
authorJonathan Salwan <jonathan.salwan@gmail.com>
Thu, 27 Jun 2013 23:51:13 +0000 (09:51 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 28 Jun 2013 06:37:21 +0000 (16:37 +1000)
commit44ff9d51b1410c0747ec07008fa9705097a2ff8d
tree486cd49af6a21cd6da49302d4175a6da73d0f639
parent7e4f24b89b9ce81014b21fec1524d933d0ba81f6
drivers/cdrom/cdrom.c: use kzalloc() for failing hardware

In drivers/cdrom/cdrom.c mmc_ioctl_cdrom_read_data() allocates a memory
area with kmalloc in line 2885.

2885         cgc->buffer = kmalloc(blocksize, GFP_KERNEL);
2886         if (cgc->buffer == NULL)
2887                 return -ENOMEM;

In line 2908 we can find the copy_to_user function:

2908         if (!ret && copy_to_user(arg, cgc->buffer, blocksize))

The cgc->buffer is never cleaned and initialized before this function.  If
ret = 0 with the previous basic block, it's possible to display some
memory bytes in kernel space from userspace.

When we read a block from the disk it normally fills the ->buffer but if
the drive is malfunctioning there is a chance that it would only be
partially filled.  The result is an leak information to userspace.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/cdrom/cdrom.c