summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Daley <mattd@bugfuzz.com>2014-04-28 19:05:20 +1200
committerWilly Tarreau <w@1wt.eu>2014-05-19 07:54:38 +0200
commitf76b441b9d5879587f53525933d27b16217ca78c (patch)
tree3f55f85352b5067932cda72f64b3fe7806fc31eb
parentd751df64d58a9927b9c4b47aa7cf20204d0ab2f6 (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> (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>
-rw-r--r--drivers/block/floppy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 5c01f747571b..19d45e6c2b9b 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -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