[3.11.y.z extended stable] Patch "floppy: ignore kernel-only members in FDRAWCMD ioctl input" has been added to staging queue

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


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

    floppy: ignore kernel-only members in FDRAWCMD ioctl input

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

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.11.y-queue

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
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Luis

------

>From 747077ddb7496a4fa2f55ce66eaaf72b209949f1 Mon Sep 17 00:00:00 2001
From: Matthew Daley <mattd at bugfuzz.com>
Date: Mon, 28 Apr 2014 19:05:20 +1200
Subject: floppy: ignore kernel-only members in FDRAWCMD ioctl input

commit ef87dbe7614341c2e7bfe8d32fcb7028cc97442c upstream.

Always clear out these floppy_raw_cmd struct members after copying the
entire structure from userspace so that the in-kernel version is always
valid and never left in an interdeterminate state.

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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 04ceb7e..1a8ab67 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3107,10 +3107,11 @@ loop:
 		return -ENOMEM;
 	*rcmd = ptr;
 	ret = copy_from_user(ptr, param, sizeof(*ptr));
-	if (ret)
-		return -EFAULT;
 	ptr->next = NULL;
 	ptr->buffer_length = 0;
+	ptr->kernel_data = NULL;
+	if (ret)
+		return -EFAULT;
 	param += sizeof(struct floppy_raw_cmd);
 	if (ptr->cmd_count > 33)
 			/* the command may now also take up the space
@@ -3126,7 +3127,6 @@ loop:
 	for (i = 0; i < 16; i++)
 		ptr->reply[i] = 0;
 	ptr->resultcode = 0;
-	ptr->kernel_data = NULL;

 	if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
 		if (ptr->length <= 0)
--
1.9.1





More information about the kernel-team mailing list