Commit a04d8ef9 authored by Matthew Daley's avatar Matthew Daley Committed by Greg Kroah-Hartman

floppy: ignore kernel-only members in FDRAWCMD ioctl input

commit ef87dbe7 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: default avatarMatthew Daley <mattd@bugfuzz.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5c5aeb0c
...@@ -3112,10 +3112,11 @@ static int raw_cmd_copyin(int cmd, void __user *param, ...@@ -3112,10 +3112,11 @@ static int raw_cmd_copyin(int cmd, void __user *param,
return -ENOMEM; return -ENOMEM;
*rcmd = ptr; *rcmd = ptr;
ret = copy_from_user(ptr, param, sizeof(*ptr)); ret = copy_from_user(ptr, param, sizeof(*ptr));
if (ret)
return -EFAULT;
ptr->next = NULL; ptr->next = NULL;
ptr->buffer_length = 0; ptr->buffer_length = 0;
ptr->kernel_data = NULL;
if (ret)
return -EFAULT;
param += sizeof(struct floppy_raw_cmd); param += sizeof(struct floppy_raw_cmd);
if (ptr->cmd_count > 33) if (ptr->cmd_count > 33)
/* the command may now also take up the space /* the command may now also take up the space
...@@ -3131,7 +3132,6 @@ static int raw_cmd_copyin(int cmd, void __user *param, ...@@ -3131,7 +3132,6 @@ static int raw_cmd_copyin(int cmd, void __user *param,
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
ptr->reply[i] = 0; ptr->reply[i] = 0;
ptr->resultcode = 0; ptr->resultcode = 0;
ptr->kernel_data = NULL;
if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
if (ptr->length <= 0) if (ptr->length <= 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment