aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Daley <mattd@bugfuzz.com>2014-04-28 03:05:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-05-05 10:46:55 -0400
commitef87dbe7614341c2e7bfe8d32fcb7028cc97442c (patch)
tree3fe51b6b5d0744320c1f785f9d2dadb01f789de1
parent89ca3b881987f5a4be4c5dbaa7f0df12bbdde2fd (diff)
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:
3121 return -ENOMEM; 3121 return -ENOMEM;
3122 *rcmd = ptr; 3122 *rcmd = ptr;
3123 ret = copy_from_user(ptr, param, sizeof(*ptr)); 3123 ret = copy_from_user(ptr, param, sizeof(*ptr));
3124 if (ret)
3125 return -EFAULT;
3126 ptr->next = NULL; 3124 ptr->next = NULL;
3127 ptr->buffer_length = 0; 3125 ptr->buffer_length = 0;
3126 ptr->kernel_data = NULL;
3127 if (ret)
3128 return -EFAULT;
3128 param += sizeof(struct floppy_raw_cmd); 3129 param += sizeof(struct floppy_raw_cmd);
3129 if (ptr->cmd_count > 33) 3130 if (ptr->cmd_count > 33)
3130 /* the command may now also take up the space 3131 /* the command may now also take up the space
@@ -3140,7 +3141,6 @@ loop:
3140 for (i = 0; i < 16; i++) 3141 for (i = 0; i < 16; i++)
3141 ptr->reply[i] = 0; 3142 ptr->reply[i] = 0;
3142 ptr->resultcode = 0; 3143 ptr->resultcode = 0;
3143 ptr->kernel_data = NULL;
3144 3144
3145 if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { 3145 if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
3146 if (ptr->length <= 0) 3146 if (ptr->length <= 0)