Skip to contentSkip to conversation

drivers-cdrom-cdromc-use-kzalloc-for-failing-hardware.patch removed from -mm tree

merged [email protected] 1 participant 1 message Jul 8, 2013 Uniform cdrom driver

lore
Share & tools
lore
#0 lore raw

Subject: [merged] drivers-cdrom-cdromc-use-kzalloc-for-failing-hardware.patch removed from -mm tree
To: [email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Mon, 08 Jul 2013 12:23:43 -0700

The patch titled
Subject: drivers/cdrom/cdrom.c: use kzalloc() for failing hardware
has been removed from the -mm tree. Its filename was
drivers-cdrom-cdromc-use-kzalloc-for-failing-hardware.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Jonathan Salwan <[email protected]>
Subject: 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.

---

 drivers/cdrom/cdrom.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cdrom/cdrom.c renamed from drivers/cdrom/cdrom.c~drivers-cdrom-cdromc-use-kzalloc-for-failing-hardware +1 -1
diff -puN drivers/cdrom/cdrom.c~drivers-cdrom-cdromc-use-kzalloc-for-failing-hardware drivers/cdrom/cdrom.c
@@ -2882,7 +2882,7 @@ static noinline int mmc_ioctl_cdrom_read
 	if (lba < 0)
 		return -EINVAL;
 
-	cgc->buffer = kmalloc(blocksize, GFP_KERNEL);
+	cgc->buffer = kzalloc(blocksize, GFP_KERNEL);
 	if (cgc->buffer == NULL)
 		return -ENOMEM;
 

_

Patches currently in -mm which might be from [email protected] are

origin.patch