[precise 2/2] floppy: don't write kernel-only members to FDRAWCMD ioctl output

Andy Whitcroft apw at canonical.com
Tue May 6 19:10:34 UTC 2014


From: Matthew Daley <mattd at bugfuzz.com>

Do not leak kernel-only floppy_raw_cmd structure members to userspace.
This includes the linked-list pointer and the pointer to the allocated
DMA space.

Signed-off-by: Matthew Daley <mattd at bugfuzz.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

(cherry picked from commit 2145e15e0557a01b9195d1c7199a1b92cb9be81f)
CVE-2014-1738
Signed-off-by: Andy Whitcroft <apw at canonical.com>
---
 drivers/block/floppy.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 56490fe..6d0f3e1 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3060,7 +3060,10 @@ static int raw_cmd_copyout(int cmd, void __user *param,
 	int ret;
 
 	while (ptr) {
-		ret = copy_to_user(param, ptr, sizeof(*ptr));
+		struct floppy_raw_cmd cmd = *ptr;
+		cmd.next = NULL;
+		cmd.kernel_data = NULL;
+		ret = copy_to_user(param, &cmd, sizeof(cmd));
 		if (ret)
 			return -EFAULT;
 		param += sizeof(struct floppy_raw_cmd);
-- 
1.9.1





More information about the kernel-team mailing list