floppy: ignore kernel-only members in FDRAWCMD ioctl input
authorMatthew Daley <mattd@bugfuzz.com>
Mon, 28 Apr 2014 07:05:20 +0000 (19:05 +1200)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 May 2014 05:54:38 +0000 (07:54 +0200)
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@bugfuzz.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit ef87dbe7614341c2e7bfe8d32fcb7028cc97442c)
[wt: be careful in 2.6.32 we still have the ugly macros everywhere]
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/block/floppy.c

index 5c01f747571b9fe34f54de72d5fa5f03641c17d7..19d45e6c2b9b001447a9a1be8fe8c1e3c67051d6 100644 (file)
@@ -3209,9 +3209,12 @@ static inline int raw_cmd_copyin(int cmd, char __user *param,
                if (!ptr)
                        return -ENOMEM;
                *rcmd = ptr;
-               COPYIN(*ptr);
+               ret = copy_from_user(ptr, (void __user *)param, sizeof(*ptr));
                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