aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Salwan <jonathan.salwan@gmail.com>2013-07-03 18:01:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-13 14:42:26 -0400
commit2842e87389ad1af50afd3fb89b7832aae7f3a7c0 (patch)
tree1b383e417ac86c2855d8c1db5e02fc36c4d96ce3
parent1b7927f047e3d71b46e36c186903fafbc9a47bf3 (diff)
drivers/cdrom/cdrom.c: use kzalloc() for failing hardware
commit 542db01579fbb7ea7d1f7bb9ddcef1559df660b2 upstream. 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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Jonathan Salwan <jonathan.salwan@gmail.com> Cc: Luis Henriques <luis.henriques@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/cdrom/cdrom.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index d620b4495745..8a3aff724d98 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2882,7 +2882,7 @@ static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi,
2882 if (lba < 0) 2882 if (lba < 0)
2883 return -EINVAL; 2883 return -EINVAL;
2884 2884
2885 cgc->buffer = kmalloc(blocksize, GFP_KERNEL); 2885 cgc->buffer = kzalloc(blocksize, GFP_KERNEL);
2886 if (cgc->buffer == NULL) 2886 if (cgc->buffer == NULL)
2887 return -ENOMEM; 2887 return -ENOMEM;
2888 2888