summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Daley <mattd@bugfuzz.com>2014-04-28 11:05:20 +0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-05-05 18:46:55 +0400
commitef87dbe7614341c2e7bfe8d32fcb7028cc97442c (patch)
tree3fe51b6b5d0744320c1f785f9d2dadb01f789de1
parent89ca3b881987f5a4be4c5dbaa7f0df12bbdde2fd (diff)
downloadlinux-ef87dbe7614341c2e7bfe8d32fcb7028cc97442c.tar.xz
floppy: ignore kernel-only members in FDRAWCMD ioctl input
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>
-rw-r--r--drivers/block/floppy.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 8f5565bf34cd..12251a688871 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3121,10 +3121,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
@@ -3140,7 +3141,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)