aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Daley <mattd@bugfuzz.com>2014-04-28 03:05:20 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-13 07:59:40 -0400
commit21506304588afab20b2d52aaa56b70e85aca6386 (patch)
treeb54ddcabf5be8cfa8b39bd7856f8c00f2bb412e9
parentabb5100737bba3f82b5514350fea89ca361ac66c (diff)
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@bugfuzz.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.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 04ceb7e2fadd..1a8ab67d1651 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3107,10 +3107,11 @@ loop:
3107 return -ENOMEM; 3107 return -ENOMEM;
3108 *rcmd = ptr; 3108 *rcmd = ptr;
3109 ret = copy_from_user(ptr, param, sizeof(*ptr)); 3109 ret = copy_from_user(ptr, param, sizeof(*ptr));
3110 if (ret)
3111 return -EFAULT;
3112 ptr->next = NULL; 3110 ptr->next = NULL;
3113 ptr->buffer_length = 0; 3111 ptr->buffer_length = 0;
3112 ptr->kernel_data = NULL;
3113 if (ret)
3114 return -EFAULT;
3114 param += sizeof(struct floppy_raw_cmd); 3115 param += sizeof(struct floppy_raw_cmd);
3115 if (ptr->cmd_count > 33) 3116 if (ptr->cmd_count > 33)
3116 /* the command may now also take up the space 3117 /* the command may now also take up the space
@@ -3126,7 +3127,6 @@ loop:
3126 for (i = 0; i < 16; i++) 3127 for (i = 0; i < 16; i++)
3127 ptr->reply[i] = 0; 3128 ptr->reply[i] = 0;
3128 ptr->resultcode = 0; 3129 ptr->resultcode = 0;
3129 ptr->kernel_data = NULL;
3130 3130
3131 if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { 3131 if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
3132 if (ptr->length <= 0) 3132 if (ptr->length <= 0)