[3.11.y.z extended stable] Patch "floppy: don't write kernel-only members to FDRAWCMD ioctl output" has been added to staging queue

Luis Henriques luis.henriques at canonical.com
Wed May 7 11:09:18 UTC 2014

This is a note to let you know that I have just added a patch titled

    floppy: don't write kernel-only members to FDRAWCMD ioctl output

to the linux-3.11.y-queue branch of the 3.11.y.z extended stable tree 
which can be found at:


If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.11.y.z tree, see



>From 8984050ec067eec38eb605df61501de40d4bce53 Mon Sep 17 00:00:00 2001
From: Matthew Daley <mattd at bugfuzz.com>
Date: Mon, 28 Apr 2014 19:05:21 +1200
Subject: floppy: don't write kernel-only members to FDRAWCMD ioctl output

commit 2145e15e0557a01b9195d1c7199a1b92cb9be81f upstream.

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>
Cc: Andy Whitcroft <apw at canonical.com>
Signed-off-by: Luis Henriques <luis.henriques 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 1a8ab67..eb3575b 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3053,7 +3053,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);

More information about the kernel-team mailing list